activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Dean <>
Subject help with ajax
Date Wed, 07 Jul 2010 19:24:16 GMT
Hello.  I'm trying out the ActiveMQ ajax messaging described at


I am able to send messages to a topic using this code:
  <script type="text/javascript" src="/amq/amq.js"></script>
    amq.sendMessage('topic://MY.DEMO', "<message item='hello again x'/ 

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>

    myHandler = {
      rcvMessage: function(message) {
        console.log( 'got message' );
myHandler.rcvMessage );

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  
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:// 
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:// 

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.


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- 
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'

View raw message