Hi, can you test the snapshot. There are some refactoring in those areas lately.
Also, try using the modified client side API, like show here http://fisheye6.atlassian.com/browse/activemq/trunk/activemq-web-demo/src/main/webapp/test/subscribe_send.html?r=HEAD BTW. messages sent to the topic before you subscribed will not be received by your subscriber. That's just how topics works. Cheers -- Dejan Bosanac - http://twitter.com/dejanb Open Source Integration - http://fusesource.com/ ActiveMQ in Action - http://www.manning.com/snyder/ Blog - http://www.nighttale.net On Wed, Jul 7, 2010 at 9:24 PM, Alex Dean <ad...@meteostar.com> wrote: > Hello. I'm trying out the ActiveMQ ajax messaging described at > http://activemq.apache.org/ajax.html. > > I am able to send messages to a topic using this code: > <script type="text/javascript" src="/amq/amq.js"></script> > <script> > amq.uri='/amq'; > amq.sendMessage('topic://MY.DEMO', "<message item='hello again x'/>"); > </script> > > When I run that snippet, I see (in the ActiveMQ admin application) that the > topic gets created and that the 'Messages Enqueued' value goes to '1'. > > Next, I try to subscribe to the topic using the following Javascript (in a > separate web page): > <script type="text/javascript" src="/amq/amq.js"></script> > <script> > amq.uri='/amq'; > > myHandler = { > rcvMessage: function(message) { > console.log( 'got message' ); > } > }; > amq.addListener('test_subscriber','topic://MY.DEMO', myHandler.rcvMessage > ); > </script> > > When I run this, I see the 'Number of Consumers' go to '1' in the admin > application. Using Firebug, I see amq.js performing a POST like > 'destination=topic://MY.DEMO&message=test_subscriber&type=listen'. This > seems to be as expected based on the tutorial. I then see amq.js perform a > series of GET requests. The first is > 'https://localhost:7998/amq?timeout=10&_=', and successive GETs are > 'https://localhost:7998/amq'. > > All of these GETs are returned with empty responses, like > '<ajax-response></ajax-response>'. The first one appears to return > immediately, and the subsequent GETs time out after maybe 20-30 seconds. > > When I next publish a new message to the topic, the 'Number of Consumers' > immediately goes to '0'. The consumer's current GET request doesn't appear > to return at this time, rather it seems to time out just like the others. > (I expected that ActiveMQ would return the message to the consumer as soon > as it was available, and then close the connection.) > > I noticed the following snippet from the logs from around the time a message > was published (while the consumer was active): > jvm 1 | DEBUG | Sent <message item='hello again x'/> to topic://MY.DEMO > jvm 1 | DEBUG | RESPONSE /demo/amq 200 > jvm 1 | DEBUG | message for ActiveMQMessageConsumer { > value=ID:rutabaga.local-63558-1278527484508-2:1:1:1, started=true > }continuation=null > jvm 1 | DEBUG | localhost removing consumer: > ID:rutabaga.local-63558-1278527484508-2:1:1:1 for destination: > topic://MY.DEMO > > I have 2 questions at the moment: > 1. Why does my consumer not receive the messages published to the topic? > 2. Why is my consumer unsubscribed when a message is sent? > > Any help is appreciated. > > regards, > alex > > My environment: > Mac OSX 10.5.6 > ActiveMQ 5.3.2 > > java version "1.5.0_22" > Java(TM) 2 Runtime Environment, Standard Edition (build > 1.5.0_22-b03-333-9M3125) > Java HotSpot(TM) Client VM (build 1.5.0_22-147, mixed mode, sharing) > > Apache is listening on port 7998. > Apache is proxying requests to ActiveMQ using the directive 'ProxyPass /amq > http://localhost:8161/demo/amq' >