View Full Version : How to extend a proxy to work over a messagequeue

23 Dec 2010, 4:33 AM

I have a implemented a MessageQueue for all my communications between the client and server and I like to extend a proxy to do its communications over the messagequeue (singleton).
It is similar to Ext.Direct but it is far more functional and existed way before ext.Direct using it is no option I have to rewrite tons of code.

little background about the MessagQueue
* The MessageQueue (MQ) is a singleton.

* The "application" has to register with the MQ so the MQ can raise an event when data is available.This way MQ.Register("EVTName"), When data is received the proper event is raised and the incoming message is passed.

*The "application" can add data to the local queue or it can instruct the MQ to send it straight away. In the last case all the stored messages are send too.

*The MQ uses a poll mechanism to see if there is data on the server for this client-connection, with a poll, any stored messages are send too.

*Data is send to the MQ with MQ.Add(Message,SendNow) where SendNow is a boolean indicating store and wait(false)
Message is a json object in the form: {HeaderParam1:Value,HeaderParam2,value,Payload:Object} a typical message could be:

I would like to extend memoryProxy (or JSONProxy, probably better, not sure) so it does its communications via the MQ but I am puzzled how to do this. Any tips are highly appreciated.


23 Dec 2010, 5:00 AM
JsonProxy? Ext JS doesn't have a JsonProxy. Is this a Sencha Touch question?

You only need to extend DataProxy and write a request() method.

23 Dec 2010, 5:30 AM
Sorry, I confused stuff typing my question, I meant JSONStore. I am very confused with all this data stuff. I have been a low level programmer for over 30 years and I am having huge trouble understanding all this weird javascript stuff, sorry.

No it is ExtJS. I feel like I have to learn Chinese in the middle of China and nobody speaks any language I understand. I have huge trouble to find proper documentation for what I need to do. The API docs are way to sparse on info if anyone is so unsure about what I need to do.

'Only write a request() method' points me in the right direction but still does not help me much:

When I look at the code for DataProxy:

request : function(action, rs, params, reader, callback, scope, options) {
if (!this.api[action] && !this.load) {
throw new Ext.data.DataProxy.Error('action-undefined', action);
params = params || {};
if ((action === Ext.data.Api.actions.read) ? this.fireEvent("beforeload", this, params) : this.fireEvent("beforewrite", this, action, rs, params) !== false) {
this.doRequest.apply(this, arguments);
else {
callback.call(scope || this, null, options, false);

and then at the API docs:

request( String action, Ext.data.Record/Ext.data.Record[]/null rs, Object params, Ext.data.DataReader reader, Function callback, Object scope, Object options ) : void
All proxy actions are executed through this method. Automatically fires the "before" + action event

It does not help me much.

What about API?
What about URL's?

What about the parameters?

I suspect I need to change the doRequest, but this calls this.load and this.load is null?

I keep running in circles, so a little more detail in an answer is the only way I am helped out..


23 Dec 2010, 5:47 AM
Digging in the code of API.js it seems that the subject of this tread is a bit wrong (It might not be).

It is all about changing the transport layer for data since this is handled in in my MQ.
I might very well set the header parameters in the URL and read these in my MQ adapter.

in API.js I see HTTP response codes and these are handled in my MQ


23 Dec 2010, 5:54 AM
Maybe it's easier to extend HttpProxy and override the doRequest method.

And you could of course also use a normal DirectProxy, but write your own read api method.