JBoss.orgCommunity Documentation

Chapter 46. Interoperability

46.1. Stomp
46.1.1. Native Stomp support
46.1.2. Mapping Stomp destinations to HornetQ addresses and queues
46.1.3. STOMP and connection-ttl
46.1.4. Stomp and JMS interoperabilty
46.1.5. Stomp Over Web Sockets
46.1.6. StompConnect
46.2. REST
46.3. AMQP

Stomp is a text-orientated wire protocol that allows Stomp clients to communicate with Stomp Brokers.

Stomp clients are available for several languages and platforms making it a good choice for interoperability.

As explained in Chapter 9, Mapping JMS Concepts to the Core API, JMS destinations are also mapped to HornetQ addresses and queues. If you want to use Stomp to send messages to JMS destinations, the Stomp destinations must follow the same convention:

  • send or subscribe to a JMS Queue by prepending the queue name by jms.queue..

    For example, to send a message to the orders JMS Queue, the Stomp client must send the frame:

    SEND
    destination:jms.queue.orders
    
    hello queue orders
    ^@
                    
  • send or subscribe to a JMS Topic by prepending the topic name by jms.topic..

    For example to subscribe to the stocks JMS Topic, the Stomp client must send the frame:

    SUBSCRIBE
    destination:jms.topic.stocks
    
    ^@
                    

HornetQ also support Stomp over Web Sockets. Modern web browser which support Web Sockets can send and receive Stomp messages from HornetQ.

To enable Stomp over Web Sockets, you must configure a NettyAcceptor with a protocol parameter set to stomp_ws:

<acceptor name="stomp-ws-acceptor">
	<factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
	<param key="protocol" value="stomp_ws"/>
	<param key="port" value="61614"/>
</acceptor>
         

With this configuration, HornetQ will accept Stomp connections over Web Sockets on the port 61614 with the URL path /stomp. Web browser can then connect to ws://<server>:61614/stomp using a Web Socket to send and receive Stomp messages.

A companion JavaScript library to ease client-side development is available from GitHub (please see its documentation for a complete description).

The stomp-websockets example shows how to configure HornetQ server to have web browsers and Java applications exchanges messages on a JMS topic.

StompConnect is a server that can act as a Stomp broker and proxy the Stomp protocol to the standard JMS API. Consequently, using StompConnect it is possible to turn HornetQ into a Stomp Broker and use any of the available stomp clients. These include clients written in C, C++, c# and .net etc.

To run StompConnect first start the HornetQ server and make sure that it is using JNDI.

Stomp requires the file jndi.properties to be available on the classpath. This should look something like:

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://localhost:1099
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

Make sure this file is in the classpath along with the StompConnect jar and the HornetQ jars and simply run java org.codehaus.stomp.jms.Main.

REST support coming soon!

AMQP support coming soon!