1 Reply Latest reply on Apr 12, 2013 6:15 PM by igarashitm

    How to order messages that are sent from the message queue?

    puttime

      I have a test application which pumps about 1000 messages to the (hornetQ) message queue.

       

      These messages get consumed by the service, but I noticed that messages don't get processed in the order they were sent.

       

      For example, from the server logs, I see this:

      (I append the "index" of the message to the name)

       

      07:15:15,817 INFO [stdout] (Thread-154 (HornetQ-client-global-threads-7498300)) episode9-test2:: Hello dippy973

       

      07:15:15,817 INFO [stdout] (Thread-143 (HornetQ-client-global-threads-7498300)) episode9-test2:: Hello dippy903

       

      07:15:15,817 INFO [stdout] (Thread-150 (HornetQ-client-global-threads-7498300)) episode9-test2:: Hello dippy924

       

      07:15:15,817 INFO [stdout] (Thread-122 (HornetQ-client-global-threads-7498300)) episode9-test2:: Hello dippy875

       

      07:15:15,817 INFO [stdout] (Thread-155 (HornetQ-client-global-threads-7498300)) episode9-test2:: Hello dippy929

       

       

      How can I make sure the messages get processed in order?

       

       

       

       

        • 1. Re: How to order messages that are sent from the message queue?
          igarashitm

          Message Group should help you to do that:

          http://docs.jboss.org/hornetq/2.2.14.Final/user-manual/en/html_single/index.html#message-grouping

           

          If you send those messages via the connection factory which has Message Group enabled, then the messages should be received in right order.

          I used RemoteConnectionFactory to send messages, so I changed the standalone-full.xml like this:

           

          $ diff -uNr standalone-full.xml.orig standalone-full.xml
          --- standalone-full.xml.orig          2013-04-13 07:03:43.392481133 +0900
          +++ standalone-full.xml          2013-04-13 06:59:57.673834098 +0900
          @@ -330,6 +330,7 @@
                                       <entry name="RemoteConnectionFactory"/>
                                       <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
                                   </entries>
          +                        <group-id>MessageGroup0</group-id>
                               </connection-factory>
                               <pooled-connection-factory name="hornetq-ra">
                                   <transaction mode="xa"/>
          
          

           

          The other option is to limit the number of delivery thread to just one, but the parameter called "max-pool-size" is only available for JBossAS 7.2 or later.

          https://github.com/jbossas/jboss-as/blob/master/build/src/main/resources/docs/schema/jboss-as-messaging_1_3.xsd#L836

          1 of 1 people found this helpful