activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lilyruo <>
Subject ActiveMQ AJax Client
Date Mon, 26 Apr 2010 21:45:15 GMT

I try to write a simple Ajax client to send and receive messages. It's
successfully deployed but I have never received msg from the client. I am
beating myself to think out what I am missing, but still can't make it work. 

Here is my code:
1) I creat a dynamic web application named: ActiveMQAjaxService and put
activemq-web.jar and all neccessary dependencies in the WEB-INF/lib folder.
In this way, AjaxServlet and MessageServlet will be deployed
2) I start activemq server in command line: ./activemq => activemq
successfully created and display:
Listening for connections at: tcp://lilyubuntu:61616
 INFO | Connector openwire Started
 INFO | ActiveMQ JMS Message Broker (localhost,
ID:lilyubuntu-56855-1272317001405-0:0) started
 INFO | Logging to org.slf4j.impl.JCLLoggerAdapter(org.mortbay.log) via
 INFO | jetty-6.1.9
 INFO | ActiveMQ WebConsole initialized.
 INFO | Initializing Spring FrameworkServlet 'dispatcher'
 INFO | ActiveMQ Console at
 INFO | Initializing Spring root WebApplicationContext
 INFO | Connector vm://localhost Started
 INFO | Camel Console at
 INFO | ActiveMQ Web Demos at
 INFO | RESTful file access application at
 INFO | Started SelectChannelConnector@

3) index.xml, which is the html to test the client:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="amq/amq.js"></script>
<script type="text/javascript">amq.uri='amq';</script>
<title>Hello Ajax ActiveMQ</title>
<p>Hello World!</p>
<script type="text/javascript">
amq.sendMessage("topic://myDetector", "message");
var myHandler = 
  rcvMessage: function(message) 
     alert("received "+message);

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

4) Web.xml:
<?xml version="1.0" encoding="UTF-8"?>
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

    <display-name>ActiveMQ Web Demos</display-name>
    Apache ActiveMQ Web Demos

    <!-- context config -->
        <param-value>vm://localhost</param-value> (I also tried
        <description>The URL of the Message Broker to connect

        <description>Whether we should include an embedded broker or

    <!-- servlet mappings -->
    <!-- the subscription REST servlet -->

        Uncomment this parameter if you plan to use multiple consumers over


    <!-- the queue browse servlet -->

After all of these, I deploy the web-app, and it's successfully deployed,
but when I try it out in
http://localhost:8080/ActiveMQAjaxService/index.html , nothing happens. 

I can run the demo portfolioPublisher demo successfully at
http://localhost:8161/demo/portfolio/portfolio.html, and see the numbers
updated all the time. But for my simple web-app, nothing really works.

Any suggestion/hint is welcomed. Thanks so much


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

View raw message