Change logging levels and discovered a bit more about the problem.

 1. start broker & start a publisher script
 2. view ajax page in browser.  receiving messages normally
 3. shut down broker
 4. close browser window
 5. start broker
 6. start publisher
 7. view page again in browser

This is what my logs show for the first request after the browser loads in #7 
above:

DEBUG | REQUEST /demo/amq on 
org.eclipse.jetty.server.nio.selectchannelconnecto...@4cb0f24a
DEBUG | servlet=AjaxServlet
DEBUG | servlet holder=
DEBUG | REQUEST /demo/amq on 
org.eclipse.jetty.server.nio.selectchannelconnecto...@7559f3f0
DEBUG | servlet=AjaxServlet
DEBUG | servlet holder=
DEBUG | Got Session ID 3xgrpw116ot7 from cookie
DEBUG | 
sessionmanager=org.eclipse.jetty.server.session.hashsessionmana...@576f8789
DEBUG | session=null
DEBUG | chain=
DEBUG | call filter session
DEBUG | Got Session ID 3xgrpw116ot7 from cookie
DEBUG | 
sessionmanager=org.eclipse.jetty.server.session.hashsessionmana...@576f8789
DEBUG | session=null
DEBUG | chain=
DEBUG | call filter session
DEBUG | call servlet AjaxServlet
DEBUG | call servlet AjaxServlet
DEBUG | GET client=org.apache.activemq.web.webcli...@513e86ec 
session=7ly2kihm6481 uri=/demo/amq 
query=timeout=45000&d=1285186135767&r=0.6001447476869052
DEBUG | POST client=org.apache.activemq.web.webcli...@600c199f 
session=sca25cn0nuu3 info=null contentType=application/x-www-form-urlencoded; 
charset=UTF-8
DEBUG | doMessage timeout=25000
DEBUG | sensors (topic)
DEBUG | RESPONSE /demo/amq  200
DEBUG | return with suspended request
DEBUG | Setting up new connection id: 
ID:rutabaga.local-60310-1285186041188-3:1, address: vm://localhost#2
DEBUG | localhost adding consumer: 
ID:rutabaga.local-60310-1285186041188-3:1:-1:1 for destination: 
topic://ActiveMQ.Advisory.TempQueue,topic://ActiveMQ.Advisory.TempTopic
DEBUG | 0 destination=topic://sensors message=test type=listen
DEBUG | topic://sensors is a org.apache.activemq.command.ActiveMQTopic
DEBUG | localhost adding consumer: 
ID:rutabaga.local-60310-1285186041188-3:1:1:1 for destination: topic://sensors
DEBUG | localhost adding destination: 
topic://ActiveMQ.Advisory.Consumer.Topic.sensors
DEBUG | Subscribed: ActiveMQMessageConsumer { 
value=ID:rutabaga.local-60310-1285186041188-3:1:1:1, started=true } to 
topic://sensors id=test
DEBUG | RESPONSE /demo/amq  200
DEBUG | message for ActiveMQMessageConsumer { 
value=ID:rutabaga.local-60310-1285186041188-3:1:1:1, started=true 
}continuation=null
DEBUG | remove: ID:rutabaga.local-60310-1285186041188-3:1:1:1, 
lastDeliveredSequenceId:0
DEBUG | localhost removing consumer: 
ID:rutabaga.local-60310-1285186041188-3:1:1:1 for destination: topic://sensors

My browser never receives the data which is being published to the topic.  The 
last line ('removing consumer...') seems problematic here.

When I close the browser window and open it again, I get...

DEBUG | REQUEST /demo/amq on 
org.eclipse.jetty.server.nio.selectchannelconnecto...@7559f3f0
DEBUG | servlet=AjaxServlet
DEBUG | servlet holder=
DEBUG | Got Session ID 7ly2kihm6481 from cookie
DEBUG | 
sessionmanager=org.eclipse.jetty.server.session.hashsessionmana...@576f8789
DEBUG | 
session=org.eclipse.jetty.server.session.HashSessionManager$Session:7ly2kihm6...@496418976
DEBUG | chain=
DEBUG | call filter session
DEBUG | call servlet AjaxServlet
DEBUG | GET client=org.apache.activemq.web.webcli...@17cb0a16 
session=7ly2kihm6481 uri=/demo/amq 
query=timeout=45000&d=1285186383593&r=0.9412045402828407
DEBUG | doMessage timeout=25000
DEBUG | RESPONSE /demo/amq  200
DEBUG | return with suspended request
DEBUG | REQUEST /demo/amq on 
org.eclipse.jetty.server.nio.selectchannelconnecto...@2d11f5f1
DEBUG | servlet=AjaxServlet
DEBUG | servlet holder=
DEBUG | Got Session ID 7ly2kihm6481 from cookie
DEBUG | 
sessionmanager=org.eclipse.jetty.server.session.hashsessionmana...@576f8789
DEBUG | 
session=org.eclipse.jetty.server.session.HashSessionManager$Session:7ly2kihm6...@496418976
DEBUG | chain=
DEBUG | call filter session
DEBUG | call servlet AjaxServlet
DEBUG | POST client=org.apache.activemq.web.webcli...@17cb0a16 
session=7ly2kihm6481 info=null contentType=application/x-www-form-urlencoded; 
charset=UTF-8
DEBUG | sensors (topic)
DEBUG | Setting up new connection id: 
ID:rutabaga.local-60310-1285186041188-3:2, address: vm://localhost#4
DEBUG | localhost adding consumer: 
ID:rutabaga.local-60310-1285186041188-3:2:-1:1 for destination: 
topic://ActiveMQ.Advisory.TempQueue,topic://ActiveMQ.Advisory.TempTopic
DEBUG | 0 destination=topic://sensors message=test type=listen
DEBUG | topic://sensors is a org.apache.activemq.command.ActiveMQTopic
DEBUG | localhost adding consumer: 
ID:rutabaga.local-60310-1285186041188-3:2:1:1 for destination: topic://sensors
DEBUG | Subscribed: ActiveMQMessageConsumer { 
value=ID:rutabaga.local-60310-1285186041188-3:2:1:1, started=true } to 
topic://sensors id=test
DEBUG | RESPONSE /demo/amq  200
DEBUG | message for ActiveMQMessageConsumer { 
value=ID:rutabaga.local-60310-1285186041188-3:2:1:1, started=true 
}continuation=org.eclipse.jetty.server.asynccontinuat...@24cc0f9f@ASYNCWAIT
DEBUG | async request
DEBUG | REQUEST /demo/amq on 
org.eclipse.jetty.server.nio.selectchannelconnecto...@7559f3f0
DEBUG | servlet=AjaxServlet
DEBUG | servlet holder=
DEBUG | 
sessionmanager=org.eclipse.jetty.server.session.hashsessionmana...@576f8789
DEBUG | 
session=org.eclipse.jetty.server.session.HashSessionManager$Session:7ly2kihm6...@496418976
DEBUG | chain=
DEBUG | call filter session
DEBUG | call servlet AjaxServlet
DEBUG | GET client=org.apache.activemq.web.webcli...@17cb0a16 
session=7ly2kihm6481 uri=/demo/amq 
query=timeout=45000&d=1285186383593&r=0.9412045402828407
DEBUG | doMessage timeout=25000
DEBUG | RESPONSE /demo/amq  200

At this point, my client is receiving messages normally.  But why do I have to 
refresh the page twice in order to make this happen?

thanks,
alex


On Sep 22, 2010, at 1:40 PM, Alex Dean wrote:

> 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?
> 
> thanks,
> alex

Reply via email to