activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Dean <>
Subject ajax clients must refresh browser to get data
Date Wed, 22 Sep 2010 18:40:13 GMT
I am trying to track down a problem we see when using activemq+ajax.  Sometimes when a web
page (which uses amq.js) is first loaded, the amq.js POST & GET requests will be made
as normal, but no data is returned even though there are messages being published to the desired
topic.  Each GET just returns with an empty <ajax-response></ajax-response>. 
If we refresh the browser, making no changes to the message publisher or the broker, then
we are able to start receiving messages.

The most reliable way I'm able to reproduce is as follows:
 - Open a web browser and view a page using amq.js.
 - Restart the broker.  The client will (as expected) get error responses when trying to contact
the dead broker.  The client will wait a few seconds after the error, and then try again.
 - Restart the message publisher.  Mine (written in Ruby/stomp) always terminates when the
broker shuts down.
 - After the broker is fully started, the client will again get 200 responses to its GET requests,
but no messages will be received. (Although they are being published to the topic.)
 - Refresh the browser.  Again, GET requests will be accepted and appear normal, but no data
is received.
 - Refresh the browser again.  At this point, messages are received normally.

I have been able to see via Firefox/Firebug that after the server restarts, the client does
get a new JSESSIONID value, which is then sent back to the server with subsequent requests.
 It doesn't surprise me that the client doesn't get messages after the broker restarts, since
I expect the client needs to re-send the 'listen' POST.  But why a simple refresh doesn't
achieve this, I don't know.

I'm seeing similar behavior if I view data via ajax, then leave that web page for some amount
of time (not sure what the time is, still trying to pin it down more precisely), and then
visit the page again.  The first time I load the page after a prolonged absence, I don't get
any data.  Ajax GET & POST requests are made, and activemq responds with empty <ajax-response>
messages, though there are messages being published to the topic.   No data is received until
I refresh the browser.

I don't know much about continuations, but could they be involved with this problem?

View raw message