You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by lsgmasa <mn...@namco.com> on 2009/10/31 03:35:57 UTC

Ajax AddListener(...)

http://old.nabble.com/file/p26139375/testindex.html testindex.html 
http://old.nabble.com/file/p26139375/testindex.js testindex.js 

Hello 

I am using activeMQ 5.2.0, and to send data between c++ code and web browser
(firefox and ie).

It works good when I am sending the data from web browser to c++ code, but
when I send data from c++ to web browser, the message listener doesn't get
called once in a while, and the message seems lost.

Once the web browser becomes not to able to receive the messages, then it
doesn't receive any message for a while, but after that it starts receiving
messages again.

to make sure if ActiveMQ server is forwarding the message from c++ code to
the web browser, I launched 2 web browsers on different computers. The both
of them were listening to the same topic. At the beginning, if I send data
from the c++ code, the both of web browsers receive the data. However, after
while, once one of them stops receiving data, although the other keeping
receiving it. Therefore, I believe the data is forwarded to the both web
browsers, but one the one computer, somewhere at the amq.js level or lower,
the messages seems ignored or lost.

I allocated 3 programmers here to debug this problem, but so far no luck. If
anyone provides us with any info, idea, or whatever, I really appreciate it.

Thanks




-- 
View this message in context: http://old.nabble.com/Ajax-AddListener%28...%29-tp26139375p26139375.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Ajax AddListener(...)

Posted by lsgmasa <mn...@namco.com>.
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...


http://old.nabble.com/file/p26223939/amq.zip amq.zip  

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/
                                                             amq.js
                                                             _amq.js
                                                             behaviour.js
                                                             prototype.js
                                                     






-- 
View this message in context: http://old.nabble.com/Ajax-AddListener%28...%29-tp26139375p26223939.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.