activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Interition <paul.worr...@interition.net>
Subject AJAX
Date Thu, 22 Jun 2006 11:37:07 GMT

I am trying to familiarise myself with
org.apache.activemq.web.MessageListenerServlet to publish and subscribe to
ActiveMQ topics.

The servlet is working and logging so I can monitor it.  I have a simple
publisher that appears to be able to post to a specified topic but my simple
subscriber just never seems to receive anything.  Help appreciated big time. 
Snippets below...

MessagePublisher.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
    <head>
        <title>Message Publishing</title>
        <script type="text/javascript" src="js/prototype.js"></script>
        <script type="text/javascript" src="js/behaviour.js"></script>
        <script type="text/javascript" src="js/_amq.js"></script>
        <script type="text/javascript">amq.uri='amq';</script>
        <script type="text/javascript">
                function publishMessage() {
                  amq.sendMessage("topic://MY.TEST","<data><item>Hello
World</item></data>");
                 }
        </script>
    </head>
    <body>
        <form action="#">
            <input type="button" value="Publish Message"
onclick="publishMessage();"/>
        </form>
    </body>
</html>


MessageListener.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
    <head>
        <title>MessageListener Test</title>
        <script type="text/javascript" src="js/prototype.js"></script>
        <script type="text/javascript" src="js/behaviour.js"></script>
        <script type="text/javascript" src="js/_amq.js"></script>
        <script type="text/javascript">amq.uri='amq';</script>
        <script type="text/javascript">
                var feedHandler = 
                {
                  _feed: function(message) 
                  {
                        alert("received: " +message);
                        document.getElementById("result").innerHTML =
message;
                    }
                  }
                };

                function chartPoll(first)
                {
                   if (first)
                   {
                    
amq.addListener('charts','topic://MY.TEST',feedHandler._feed);
                   }
                }

                amq.addPollHandler(chartPoll);
        </script>
    </head>
    <body>
        <h1>Message Listener</h1>
        <hr/>
        <div id="result"></div>
    </body>
</html>
--
View this message in context: http://www.nabble.com/AJAX-t1829608.html#a4991458
Sent from the ActiveMQ - User forum at Nabble.com.


Mime
View raw message