Reputation: 7285
I am testing the basic ActiveMQ AjaxServlet service to communicate with a back end ActiveMQ service. The issue I am having is that the time it takes to receive the message from the queue using the ajax client is sometimes 20+ seconds. The length of the delay is completely different every time but it is long enough that I am concerned about going forward with the solution. I have tried the prototype adapter and the jquery adapter and both exhibit the same issues. I have tried multiple browsers and the same issues persists. I have excellent connectivity with the remote queue and there is no delay there.
Edit
I see that the message is being delayed 25 seconds which is the timeout of the ajax connection. I don't think this is the correct behavior and it should break when the message is received,then reconnect. Is this the correct assumption?
ActiveMQ Version : 5.9.0
Firefox: 28
Chrome: Newest Release
Tomcat: 7.0.52
web.xml
<context-param>
<param-name>org.apache.activemq.brokerURL</param-name>
<param-value>tcp://remoteaddress.example:61616</param-value>
</context-param>
<servlet>
<servlet-name>AjaxServlet</servlet-name>
<servlet-class>org.apache.activemq.web.AjaxServlet</servlet-class>
<async-supported>true</async-supported>
</servlet>
<servlet>
<servlet-name>MessageServlet</servlet-name>
<servlet-class>org.apache.activemq.web.MessageServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>MessageServlet</servlet-name>
<url-pattern>/q/message/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AjaxServlet</servlet-name>
<url-pattern>/q/ajax/*</url-pattern>
</servlet-mapping>
Javascript
<script type="text/javascript" src="js/amq/prototype.js"></script>
<script type="text/javascript" src="js/amq/amq_prototype_adapter.js"></script>
<script type="text/javascript" src="js/amq/amq.js"></script>
<script type="text/javascript">
var amq = org.activemq.Amq;
amq.init({
uri: 'q/ajax',
logging: true
});
var myHandler =
{
rcvMessage: function(message)
{
alert("received "+message);
}
};
var myDestination='queue://com.broadworks.dms.client';
var myMessage = '<message>foooooo barrrr</message>';
var myId = '1231234';
amq.addListener(myId, myDestination, myHandler.rcvMessage);
try {
amq.sendMessage(myDestination, myMessage);
} catch (err) {
alert(err);
}
</script>
Upvotes: 1
Views: 1001
Reputation: 17874
It's a regression bug! I provided a patch at https://issues.apache.org/jira/browse/AMQ-5182. Compiled version at https://bitbucket.org/greyfairer/apache-activemq/downloads
Upvotes: 0
Reputation: 421
I used to use ActiveMQ's JavaScript library for building web apps that connected to ActiveMQ. I switched to using their websockets interface though and never went back. Just turn on the websocket interface as described here: http://activemq.apache.org/mqtt.html. Then use the STOMP over WebSocket library from here: http://jmesnil.net/stomp-websocket/doc/
Upvotes: 2