activeMQ AJAX and zk [solved]

asked 2013-02-05 13:18:30 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16

updated 2013-02-24 23:05:30 +0800

Hi all,

i'm trying to get access from a web app to an activeMQ messaging server with their AJAX api. Does anyone have successfull run a polling from out a zul-file?

I cannot find out what is the problem:

thanks Stephan

pieces of zul:

<script type="text/javascript" src="js/amq/jquery-1.4.2.min.js"></script> 
<script type="text/javascript" src="js/amq/amq_jquery_adapter.js"></script>
<script type="text/javascript" src="js/amq/amq.js"></script>
<script type="text/javascript">amq.uri='/amq';</script>

<script type="text/javascript">
    var amq = org.activemq.Amq; 

      uri: 'amq', 
      logging: true, 
      timeout: 45 

<script type="text/javascript">
    amq.sendMessage("topic://myDetector", "message");

    var myHandler = { rcvMessage: function(message) { alert("received " +message); lbl_test.setValue(message); } };

    function myPoll(first) { if (first) { amq.addListener('myDetector', 'topic://myDetector', myHandler.rcvMessage);
    } }


<script type="text/javascript">function sendMessage(){ amq.sendMessage("topic://myDetector", "message"); }</script>
<script type="text/javascript">function sayHello(){alert("Hello");}</script>

<button label="sendMessage" onClick='Clients.evalJavaScript("sendMessage()")' />
<button label="alert" onClick='Clients.evalJavaScript("sayHello()")' />

pieces of web.xml

<!-- activeMQ -->
<!-- ActiveMQ AjaxServlet -->
<!-- The servlet both serves the required js files and handles the JMS requests and responses -->

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted

answered 2013-02-23 08:28:49 +0800

windeyu gravatar image windeyu flag of United States
288 3

updated 2013-02-23 08:38:00 +0800

Hi Stephan,

I got the polling working from my zul page. I don't know what issues you encountered, but I initially encountered issues, like some camel classes not found, continuations not supported, and illegal state. Finally I found the following link. The second last post helped me get the polling to work. http://activemq.2283324.n4.nabble.com/AjaxServlet-on-Tomcat-td3601798.html

Here are my additional libraries for your reference.

  • camel-core-2.10.3.jar
  • activemq-all-5.8.0.jar
  • activemq-web-5.8.0.jar
  • jetty-all-server-8.1.8.v20121106.jar

I'm running apache-tomcat-7.0.32. I must have "MessageServlet" registered in web.xml, as suggested by the post. Also, my client page must first make the call, amq.sendMessage(destination, message), before the polling starts to work from there on. I was able to use JConsole to send some testing message to a topic, and saw my client page polled and displayed it on the screen.

Lastly, I didn't try your code. I followed the pattern in the smalltalk to integrate activemq js.

I hope this information help.

link publish delete flag offensive edit

answered 2013-02-24 19:18:43 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16

updated 2013-02-25 08:56:24 +0800

Thanks windeyu, i have get it to run in the meantime. For asynchronous working the activeMQ listeners need an entry in the web.xml.


(listeners and filters in web.xml) I realize that this can only be run in a servlet-api 3.0 specification. Tomcat 6.x does not support this out of the box. Now it runs in Glassfish and Tomcat 7.0.35

Thanks Stephan

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2013-02-05 13:18:30 +0800

Seen: 54 times

Last updated: Feb 25 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More