activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lsgmasa <>
Subject Re: Ajax AddListener(...)
Date Thu, 05 Nov 2009 23:06:34 GMT

Finally I found a solution.
It seems the problem was _amq.js. 
BTW, this problem happens even with the demo web page (chat.html)
when you reload the page a few times, you stop seeing the messages in the
text box when you send a new message.

anyway, the problem is in the poll functions in _amq.js.

new Ajax.Request(amq.uri, { method: 'get', parameters: 'timeout=0',
onSuccess: amq._pollHandler });

the script tries to send the 'get' to the web server, but since the 'get'
commands are exactly same every time it sends, the web browsers don't send
the command to the web server, and it uses cached data. There is a post in
this forum long time ago telling this problem. However the post says it
happens only with IE6, so I ignored the post.  After spending so many hours,
I found this happens with the new IE 8 and FireFox 3.5.4.

Work-arround is to include different data in the 'get' request as the other
post in this forum says:

var timeout = 40;
var now = new Date();
var data = 'timeout=' + timeout * 1000
           + '&d=' + now.getTime()
           + '&r=' + Math.random();

new Ajax.Request(amq.uri, { method: 'get', data: data, parameters:
'timeout=0', onSuccess: amq._pollHandler });

I am surprised that this has not been fixed since the post is old, and I
thought there are so many people are using this technology...  

I attached my version _amq.js along with other js files, so that other
people who have the same problem can download and use it.

you should extract the zip in the webapp root directory where your html
calls the following functions:
<script type="text/javascript" src="amq/amq.js"></script>
<script type="text/javascript">amq.uri='amq';</script>

e.g. for activemq demo web site, put them like:

your activemq install dir/webapss/demo/amq/

View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message