10 Replies Latest reply on Feb 28, 2011 9:25 AM by Rishi Dev

    Performance = Stomp vs JMS

    Rishi Dev Newbie

      Hi,

       

      I did some tests with HornetQ using both Stomp and JMS clients.

      I tested with large size text msgs (each msg of about ~3 MB) and a volume of about 20000 msgs.

      I see that by using JMS I was able to push each msg in approx 0.5 second while in case of Stomp each msg is taking about 30 seconds.

       

      So is this difference in performance reasonable? Should I be doing some config changes?

       

      Please feel free to ask for any information you might need to help me with this.

       

      Thanks

      Rishi

        • 1. Performance = Stomp vs JMS
          Clebert Suconic Master

          That has been fixed on trunk already.

          • 2. Performance = Stomp vs JMS
            Rishi Dev Newbie

            Clebert,

             

            Just to confirm I am using 2.1.2-Final and the fix was not in that, right?

            Also is there any place where I can download nightly builds or I need to build it myself?

             

            Thanks,

            Rishi

            • 4. Performance = Stomp vs JMS
              Rishi Dev Newbie

              Clebert,

               

              I did a build of HornetQ 2.2.0-CR1 from trunk in local environment and tested Stomp, but it appears that performance is still slow.

              Here is how I am doing Stomp client, it is basically from one of the samples provided with HornetQ.

               

                           // Step 1. Create a TCP socket to connect to the Stomp port

                           Socket socket = new Socket("localhost", 61613);

               

                           // Step 2. Send a CONNECT frame to connect to the server

                           String connectFrame = "CONNECT\n" +

                              "login: guest\n" +

                              "passcode: guest\n" +

                              "request-id: 1\n" +

                              "\n" +

                              END_OF_FRAME;

                           sendFrame(socket, connectFrame);

               

                           // Step 3. Send a SEND frame (a Stomp message) to the

                           // jms.queue.exampleQueue address with a text body

                           String text = "Hello, world from Stomp!";

                           Date lastTime=null;

                           String message = "SEND\n" +

                              "destination: jms.queue.ExampleQueue\n" +

                              "\n" +

                              msg +

                              END_OF_FRAME;

                           for(int i=0;i<10;i++){

                               if(lastTime==null) lastTime=new Date();

                               sendFrame(socket, message);

                               String str = "\n"+(i+1)+"," + (new Date().getTime()-lastTime.getTime());

                               fileWriter.write(str);fileWriter.flush();

                               lastTime=new Date();

                           }

                          

                           // Step 4. Send a DISCONNECT frame to disconnect from the server

                           String disconnectFrame = "DISCONNECT\n" +

                              "\n" +

                              END_OF_FRAME;

                           sendFrame(socket, disconnectFrame);

               

                           // Step 5. Slose the TCP socket

                           socket.close();

               

              Thanks,

              Rishi

              • 5. Re: Performance = Stomp vs JMS
                Reid Morrison Newbie

                The Stomp example above is included with HornetQ under the JMS examples folder and pre-dates the Stomp implementation in HornetQ and should actually be removed. There are so many excellent Stomp clients available, no one would ever need to work with Stomp at the socket level as done in the example above.

                 

                The best performance would be achieved using the HornetQ Core API, since both the JMS and Stomp API's use the Core API underneath.

                • 6. Performance = Stomp vs JMS
                  Rishi Dev Newbie

                  Thanks Reid!

                  Please suggest some Stomp clients which you would recommend as stable and good ones.

                  Gozirra? StompJ doesn't seem to have support for jdk1.4.

                   

                  Another question: Can these Stomp client libraries connect with HornetQ out of the box or do we need to setup HornetQ with StompConnect first?

                  Reference to any blog/documentation will be great.

                   

                  Thanks

                  Rishi

                  • 7. Performance = Stomp vs JMS
                    Reid Morrison Newbie

                    To enable the native Stomp connector, just add the following lines to hornetq-configuration.xml inside the <acceptors> tag:

                     

                        <acceptor name="stomp-acceptor">

                            <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>

                            <param key="protocol"  value="stomp"/>

                            <param key="port"  value="61613"/>

                        </acceptor>

                     

                    StompConnect is a separate library not part of HornetQ that was used before HornetQ had native support for Stomp.

                     

                    Don't think you will find much anything that will run on jdk1.4. We are only using Stomp for Non-Java platforms.

                    • 8. Performance = Stomp vs JMS
                      Rishi Dev Newbie

                      Thanks Reid!

                       

                      Has anyone tried HornetQ with Gozirra Stomp client?

                      If for jdk above 1.4, would you recommend any java stomp client library?

                       

                      I tested Gozirra Stomp client with HornetQ using below simple code, it does not throws any exception appears that it has sent the msg but I don't see the msg in HornetQ queues.

                       

                      Client c = new Client( "localhost", 61613, "guest", "guest");

                      c.begin();

                      c.send("ExampleQueue", "Hello Sample Msg using Stomp Gozirra!");

                      c.disconnect();

                       

                      Thanks,

                      Rishi

                      • 9. Performance = Stomp vs JMS
                        Rishi Dev Newbie

                        Btw, for c.begin() and c.send(); in HornetQ console I get these exception:

                         

                        org.hornetq.core.protocol.stomp.StompException: transaction header is mandatory to BEGIN a transaction

                                at org.hornetq.core.protocol.stomp.StompProtocolManager.onBegin(StompProtocolManager.java:391)

                                at org.hornetq.core.protocol.stomp.StompProtocolManager.doHandleBuffer(StompProtocolManager.java:194)

                                at org.hornetq.core.protocol.stomp.StompProtocolManager.handleBuffer(StompProtocolManager.java:145)

                                at org.hornetq.core.protocol.stomp.StompConnection.bufferReceived(StompConnection.java:152)

                                at org.hornetq.core.remoting.server.impl.RemotingServiceImpl$DelegatingBufferHandler.bufferReceived(RemotingServiceImpl.java:459)

                         

                        ... and ...

                         

                        org.hornetq.core.protocol.stomp.StompException: transaction header is mandatory to COMMIT a transaction

                                at org.hornetq.core.protocol.stomp.StompProtocolManager.onCommit(StompProtocolManager.java:409)

                                at org.hornetq.core.protocol.stomp.StompProtocolManager.doHandleBuffer(StompProtocolManager.java:198)

                                at org.hornetq.core.protocol.stomp.StompProtocolManager.handleBuffer(StompProtocolManager.java:145)

                                at org.hornetq.core.protocol.stomp.StompConnection.bufferReceived(StompConnection.java:152)

                                at org.hornetq.core.remoting.server.impl.RemotingServiceImpl$DelegatingBufferHandler.bufferReceived(RemotingServiceImpl.java:459)

                                at org.hornetq.core.remoting.impl.netty.HornetQChannelHandler.messageReceived(HornetQChannelHandler.java:67)

                                .........

                         

                        Where can I find the details about what header key/values are to be passed in header map?

                        • 10. Performance = Stomp vs JMS
                          Rishi Dev Newbie

                          I have integrated Gozirra based Stomp client and it's performance seems much better. For large ~3 MB size msg now it is taking about ~2.8 seconds to push each msg.

                          Here is the modified code:

                           

                          Client c = new Client( "localhost", 61613, "guest", "guest");

                          Map headers = new HashMap();

                          headers.put(Stomp.Headers.TRANSACTION, "123");

                          c.begin(headers);

                          c.send("jms.queue.ExampleQueue", msg);

                          c.disconnect();

                           

                          Now I need to understand why we are forced by HornetQ to set some TRANSACTION header and if it is something we should pass from client side then what should it really be? In my tests I have just put some random number 123.

                           

                          Thanks,

                          Rishi