6 Replies Latest reply on Feb 15, 2010 6:00 AM by Michael Justin

    How do I enable the Stomp protocol?

    Michael Justin Novice

      Hello,

       

      what is necessary to try the Stomp transport in HornetQ? Can I simply build the newest release from trunk, copy the Jar files to the 2.0.GA release and run it, or is additional configuration required?

       

      Many thanks in advance,

      Michael Justin

        • 1. Re: How do I enable the Stomp protocol?
          Jeff Mesnil Master

          you also need to configure an acceptor on the server with a "protocol" param set to "stomp".

           

          If you build the trunk, the documentation contains a section about stomp configuration.

          • 2. Re: How do I enable the Stomp protocol?
            Michael Justin Novice
            Hi Jeff,

             

            the build script does not generate the documentation on my system (Vista) but I found the description for hornetq-configuration.xml.

             

            With this configuration ...

             

                  <acceptor name="stomp">
                     <factory-class>org.hornetq.integration.transports.netty.NettyAcceptorFactory</factory-class>
                     <param key="protocol"  value="stomp"/>
                     <param key="port"  value="61613"/>
                  </acceptor>

             

            ... sending works fine, but if I try to consume the messages I get an error. Maybe there is a configuration problem or the messages have not been received as expected. I guess there is a simple command line or web admin tool which I can use to check the queues, so I will investigate this and come back if I have questions again.

             

            Connecting to URL: stomp://localhost:61613
            Consuming queue: TOOL.DEFAULT
            Using a non-durable subscription
            We are about to wait until we consume: 10 message(s) then we will shutdown
            Queue jms.queue.TOOL.DEFAULT does not exist HornetQException[errorCode=100 messa
            ge=Queue jms.queue.TOOL.DEFAULT does not exist]
                    at org.hornetq.core.server.impl.ServerSessionImpl.createConsumer(ServerS
            essionImpl.java:294)
                    at org.hornetq.core.protocol.stomp.StompSession.addSubscription(StompSes
            sion.java:159)
                    at org.hornetq.core.protocol.stomp.StompProtocolManager.onSubscribe(Stom
            pProtocolManager.java:269)
                    at org.hornetq.core.protocol.stomp.StompProtocolManager.doHandleBuffer(S
            tompProtocolManager.java:166)
                    at org.hornetq.core.protocol.stomp.StompProtocolManager.access$000(Stomp
            ProtocolManager.java:49)
                    at org.hornetq.core.protocol.stomp.StompProtocolManager$1.run(StompProto
            colManager.java:132)
                    at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(Ordere
            dExecutorFactory.java:96)
                    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source
            )
                    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
                    at java.lang.Thread.run(Unknown Source)
            • 3. Re: How do I enable the Stomp protocol?
              Andy Taylor Master
              You need to configure the queue either as a  core queue in the hornetq-cinfiguration.xml file or as a JMS queue in the hornetq-jms.xml file.
              1 of 1 people found this helpful
              • 4. Re: How do I enable the Stomp protocol?
                Jeff Mesnil Master

                Hi Michael,

                 

                I have just modified the trunk and this will impact your work.

                I removed a tentative converstion between Stomp destinations and HornetQ mapping.

                I've added doc about it. Since you can't generate it, the relevant section is:

                45.1.3. Mapping Stomp destinations to HornetQ addresses and queues

                Stomp clients deals with destinations when sending messages and subscribing. Destination names are simply strings which are mapped to some form of destination on the server - how the server translates these is left to the server implementation.

                In HornetQ, these destinations are mapped to addresses and queues. When a Stomp client sends a message (using a SEND frame), the specified destination is mapped to an address. When a Stomp client subscribes (or unsubscribes) for a destination (using a SUBSCRIBE or UNSUBSCRIBE frame), the destination is mapped to a HornetQ queue.

                45.1.3.1. Using JMS destinations

                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 Queue 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
                  
                  ^@
                                  

                 

                One thing which may not be clear if you're new to HornetQ is that messages are sent to addresses and received from queues.

                Queues are bound to addresses (they will handle messages sent to the address) but an address may have no queues.

                This means that if you send a message to an address with no queue bound, the message will be effectively be sent but will be discarded as no queue will handle it.

                As Andy says, you must create a queue bound to the address you use to send message to be able to consume the messages.

                You can use jconsole management console to see which queues are bound to an address and if messages are held in the queue.

                 

                hope that helps,

                jeff

                1 of 1 people found this helpful
                • 5. Re: How do I enable the Stomp protocol?
                  Michael Justin Novice

                  Hi Jeff,

                   

                  thanks for the documentation! I will try it in the next days.

                   

                  the second example has a small typo:

                   

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

                   

                  should be

                   

                  send or subscribe to a JMS Topic by prepending the topic name by jms.topic..

                   

                  Regards,

                  Michael

                  • 6. Re: How do I enable the Stomp protocol?
                    Michael Justin Novice

                    Hi Andy,

                     

                    thank you for the information. I will try it in the next days.

                     

                    Regards,

                    Michael