You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Woody Dickson <wo...@gmail.com> on 2008/11/22 06:21:37 UTC

Need help with connecting to ActiveMQ using AJAX

Hi,

I have been trying to use AJAX to send and receive message with ActiveMQ
without any success.
I have active-web.jar inside the war and defined the web.xml as outline in
the website.
When I run index.html, I still don't see any message being sent to
ActiveMQ.

In my index.html, I have:

<head>
<title>ActiveMQ</title>
<script type="text/javascript" src="amq.js"></script>
<script type="text/javascript">amq.uri='amq';</script>
</head>
<body>
<script type="text/javascript">
<!--amq.sendMessage("topic://test","this is my test");-->
var myHandler = { rcvDiff: function(message) {alert(message)  } };
amq.addListener("anyID","topic://test",myHandler.rcvDiff);
</script>
This is a test
</body>

my web.xml has these:

<context-param>
        <param-name>org.apache.activemq.brokerURL</param-name>
        <param-value>tcp://192.168.1.101:61616</param-value>
        <description>  The URL of the Message Broker to connect to
</description>
</context-param>

<context-param>
        <param-name>org.apache.activemq.embeddedBroker</param-name>
        <param-value>false</param-value>
        <description>Whether we should include an embedded broker or
not</description>
</context-param>

        <servlet>
      <servlet-name>AjaxServlet</servlet-name>
      <servlet-class>org.apache.activemq.web.AjaxServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>AjaxServlet</servlet-name>
        <url-pattern>/amq/*</url-pattern>
    </servlet-mapping>

    <filter>
      <filter-name>session</filter-name>
      <filter-class>org.apache.activemq.web.SessionFilter</filter-class>
    </filter>

    <filter-mapping>
      <filter-name>session</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>


Any help will be greatly appreciated.

Thanks,
Woody