activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Dean <a...@crackpot.org>
Subject Re: Problem with Ajax API
Date Tue, 21 Dec 2010 16:33:09 GMT

On Dec 21, 2010, at 9:54 AM, stratio wrote:

> 
> Hello I'm experimenting a new trouble :(
> 
> I'm still using ActiveMQ 5.4.2 on Windows 7. I'm running a Ruby client which
> creates a topic named "/topic/ActiveMQFeed" using Stomp Protocol and publish
> on it a message every 3 seconds.

You might be sending binary messages, which can't be received by ajax clients.  Check the
"Receiving messages" section of http://activemq.apache.org/ajax.html.

"Be aware that, by default, messages published via Stomp which include a content-length header
will be converted by ActiveMQ to binary messages, and will not be visible to your web clients.
Beginning with ActiveMQ 5.4.0, you can resolve this problem by always setting the amq-msg-type
header to text in messages which will may be consumed by web clients."

> 
> <script type="text/javascript" src="jquery-1.4.2.min.js"></script>
> <script type="text/javascript" src="amq_jquery_adapter.js"></script>
> <script type="text/javascript" src="amq.js"></script>
> 
> var amq = org.activemq.Amq;
> amq.init({ uri: 'amq', logging: true, timeout: 45 });
> 
> var testHandler = function(message) {
>    		alert("received "+message);
> };
> 
> amq.addListener("test", "topic://topic/ActiveMQFeed", testHandler);

Check your http://localhost:8161/admin/topics.jsp after your page loads.  Does the topic exist?
 Does the 'Number of Consumers' go up when your page loads?  Do you see messages being published
to the topic?

> 
> 
> Now if i run this code i don't see anything on the browser and on the Chrome
> Javascript debugger i get this error :
> 
> "Error occurred in poll. HTTP result: 0, status: parsererror"

What's returned by the server?  Is it maybe one of these?
 * "<ajax-response></ajax-response>" : This is what a timeout looks like.  No
messages received.
 * "<ajax-response><response id='test' destination='topic://topic/ActiveMQFeed' ></response></ajax-response>"
: This is what it looks like when the server delivers a binary message.

I recall seeing a similar error message after a timeout.  (An empty <ajax-response>
was returned, but with a content-type of 'text/plain', which made the jQuery code unable to
parse the response.)  That particular problem should be fixed, so if it's still occurring
I'd like to know.  Or your issue may be totally unrelated.

I'd be really interested to know what the server response looks like when you see this error,
including all headers and content.

regards,
alex
Mime
View raw message