jboss-6.0.0-M3: JMS over HTTP (servlet)
robert.geisler Jul 7, 2010 4:10 AMhello everybody...
currently i am testing JBoss 6.0.0 M3 and got stuck with the JMS Provider, HornetQ, as it came to HTTP/ HTTPS. i read the documentation (user manual) and followed chapter 16, 'configuring the transport', but in the end it does not work as expected.
my situation: i am running an EJB application in JBoss, which services will get used by a standalone Java client through JNDI. also the client(s) register to a JMS topic; my application sends JMS Messages to this topic to send information to the client(s). JMS works in default configuration: topic gets deployed, client uses JNDI name 'ConnectionFactory' to lookup JMS Connection Factory, is able to connect to my topic and to recieve JMS messages.
But i want to configure HornetQ for servlet transport to tunnel traffic over http to a servlet.
what i did to achieve this is as follows...
1) deploy/configure HornetQ Servlet in /deploy/hornetq-servlet.war/WEB-INF/web.xml:
{code:xml}<?xml version="1.0" encoding="UTF-8"?>
<web-app ... >
<servlet>
<servlet-name>HornetQServlet</servlet-name>
<servlet-class>
org.jboss.netty.channel.socket.http.HttpTunnelingServlet</servlet-class>
<init-param>
<param-name>endpoint</param-name>
<param-value>local:org.hornetq</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HornetQServlet</servlet-name>
<url-pattern>/HornetQServlet</url-pattern>
</servlet-mapping>
</web-app>{code:xml}
2) deploy/ configure HornetQ acceptor in /deploy/hornetq/hornetq-configuration.xml:
{code:xml}<configuration ... >
...
<acceptors>
...
<acceptor name="netty-servlet-acceptor">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
<param key="host" value="org.hornetq"/>
<param key="use-invm" value="true"/>
</acceptor>
</acceptors>
...
</configuration>{code:xml}
3) deploy/ configure HornetQ connector in /deploy/hornetq/hornetq-configuration.xml:
{code:xml}<configuration ... >
...
<connectors>
...
<connector name="netty-servlet-connector">
<factory-class>org.hornetq.core.remoting.impl.netty.NettyConnectorFactory</factory-class>
<param key="host" value="192.168.1.58"/>
<param key="port" value="28080"/>
<param key="servlet-path" value="/hornetq-servlet/HornetQServlet"/>
<param key="use-servlet" value="true"/>
</connector>
</connectors>
...
</configuration>{code:xml}
4) deploy/ configure JMS Connection Factory in /deploy/hornetq/hornetq-jms.xml:
{code:xml}<configuration ... >
...
<connection-factory name="NettyServletConnectionFactory">
<connectors>
<connector-ref connector-name="netty-servlet-connector"/>
</connectors>
<entries>
<entry name="/HTTPConnectionFactory"/>
</entries>
</connection-factory>
...
</configuration>{code:xml}
you see, i tried to stick with the documentation. but with all these configurations... the result is:
1) client looks up JMS Connection Factory through JNDI (name = "HTTPConnectionFactory"),
2) client creates JMS Connection by factory,
3) client starts JMS Connection,
4) client tries to stop JMS Connection.
{code:java}System.out.println("lookup('HTTPConnectionFactory')");
ConnectionFactory factory = (ConnectionFactory) context.lookup("HTTPConnectionFactory");
System.out.println("ConnectionFactory.createConnection()");
Connection connection = factory.createConnection();
System.out.println("Connection.start()");
connection.start();
System.out.println("Connection.stop()");
connection.stop();
System.out.println("Connection.close()");
connection.close();
System.out.println("finished.");{code:java}
when client stops the JMS Connection, HornetQ prints out a warning 'Timed out waiting for channel to close'.
however, it seems the connection will actually never been closed, because the thread does not finish; have a look at system.out:
{quote}lookup('HTTPConnectionFactory')
ConnectionFactory.createConnection()
Connection.start()
Connection.stop()
Connection.close()
07.07.2010 10:09:41 org.hornetq.core.logging.impl.JULLogDelegate warn
WARNUNG: Timed out waiting for channel to close{quote}
said all that my question are:
1) why is the connection never closed?
2) am i missing any configuration?
3) i am confused about the 'endpoint' param of HttpTunnelingServlet and 'host' param of HornetQ acceptor. what are the correct values to set??
looking forward to your answers.
thanks in advance.
robert
environment:
jboss-6.0.0.20100429-M3
HornetQ 2.1.0.BETA3
jboss bind adress: 192.168.1.58
tomcat http port: 28080