activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From patrice <patrice.canon...@gmail.com>
Subject Ajax and Tomcat 6 - based on web-demo with a non embedded broker
Date Wed, 09 Feb 2011 17:00:24 GMT

Hi ,

I use activeMQ 5.4.2

I am trying to implement a simple web demo to show log message from
different programs using ajax into a web page.

To do that, I use the basic broker, (tcp://localhost:61616).
The producer is a simple program with log4j configured to log on a jms
appender, using topic (topic name is logTopic).
If I run the example consumer with the command "ant consumer -Dtopic=true
-Dsubject=logTopic", I am able to get the log on the consumer side.

so now, the next step for me is to have the consumer into a WebApp which can
"provide" the messages to the client into a webpage using ajax.

So I looked at the ajax page : http://activemq.apache.org/ajax.html and
configure my web.xml as it is explain. The broker was not found, but I
solved it by using context-param in my web.xml

my web.xml looks like that : 
<web-app>
	<display-name>Archetype Created Web Application</display-name>

	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>WEB-INF/spring.xml</param-value>
	</context-param>

	<!-- tomcat listeners -->
	<listener>
		<listener-class>net.me.context.MyAppContextLoaderListener</listener-class>
	</listener>
	<context-param>
		<param-name>org.apache.activemq.brokerURL</param-name>
		<param-value>tcp://localhost: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 to get JMS message -->
	<servlet>
		<servlet-name>AjaxServlet</servlet-name>
		<servlet-class>org.apache.activemq.web.AjaxServlet</servlet-class>
	</servlet>
	<servlet-mapping>
		<servlet-name>AjaxServlet</servlet-name>
		<url-pattern>/amq/*</url-pattern>
	</servlet-mapping>
</web-app>

The web page code is very simple, as the market portfolio example that comes
with activeMQ distrib : 

<html>
<head>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/amq_jquery_adapter.js"></script>
<script type="text/javascript" src="js/amq.js"></script>
<script type="text/javascript">
  var amq = org.activemq.Amq;
  amq.init({ 
    uri: 'amq', 
    logging: true,
    timeout: 30,
    clientId:(new Date()).getTime().toString()
  });
</script>
<script type="text/javascript">
  var myHandler =
  {
    rcvMessage: function(message)
    {
       amq.adapter.log('receive message' + message);
       var txt = document.createTextNode(message);
       document.getElementById('list').appendChild(txt); 
    }
  };
  
  amq.addListener('testID','topic://logTopic',myHandler.rcvMessage);
  
</script>
</head>
<body>
<h2>Test !</h2>
<div id="list"></div>
</body>
</html>


but, it does not work. I traced request, there are send from the web page,
but nothing is updated,...
looking at log file I can see the following error 

java.lang.IllegalStateException: !(Jetty || Servlet 3.0 ||
ContinuationFilter)
   
org.eclipse.jetty.continuation.ContinuationSupport.getContinuation(ContinuationSupport.java:145)
   
org.apache.activemq.web.MessageListenerServlet.doMessages(MessageListenerServlet.java:301)
   
org.apache.activemq.web.MessageListenerServlet.doGet(MessageListenerServlet.java:247)
    org.apache.activemq.web.AjaxServlet.doGet(AjaxServlet.java:47)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


I searched for a long time without find any solution to solve this problem.
So do you know how to configure Tomcat to make this sample works ?

Feel free to ask for more detail if needed.

Regards,
Pat

-- 
View this message in context: http://activemq.2283324.n4.nabble.com/Ajax-and-Tomcat-6-based-on-web-demo-with-a-non-embedded-broker-tp3297683p3297683.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message