6 Replies Latest reply on Jun 16, 2010 9:43 AM by clebert.suconic

    Guaranteed Message Sequence

    ohughes

      Hi,

       

      I am looking to introduce HornetQ to allow us to balance the load of processing between machines, etc., and one thing that I need to ensure is that messages are processed in a specific order, but only for some usecases.  I know I can use the GroupID to ensure that the messages go to the same consumer, but how do I ensure that they are processed one after the other, and not simultaniously by the consumer?

       

      Thanks,
      Osian

        • 1. Re: Guaranteed Message Sequence
          clebert.suconic

          I don't understand the question...

           

          A Consumer will receive a message after another.. sequentially.

           

          So, it's up to you how you take the messages out. You take one at the time.

          • 2. Re: Guaranteed Message Sequence
            ohughes

            Ah, ok, so maybe I am confused also,  I thought that a consumer would be multi-threaded and be able to handle multiple messages at the same time.

             

            If this is not the case, then my bad!

             

            But if a consumer can handle multiple-messages at a given time then the question still stands, because the consumer could be processing one message in one thread, and the next one in another, which would cause out of synch processing.  So the next message should not come off the queue until the previous one has been completed

            • 3. Re: Guaranteed Message Sequence
              clebert.suconic

              A Consumer will call the message listener, one after another.

               

              If you have MDBs however, you will have multiple listeners. i.e. Multiple Consumers for a Single MDB.

               

              so, you could have multiple parallel requests on a MDB, but on that case you just have multiple consumers. On the case of a group-ID, all the requests will be handled by a single consumer.

               

               

              If you see anything different, it would be a bug.

              But I don't think it will be the case.

              1 of 1 people found this helpful
              • 4. Re: Guaranteed Message Sequence
                clebert.suconic
                But if a consumer can handle multiple-messages at a given time then the question still stands, because the consumer could be processing one message in one thread, and the next one in another, which would cause out of synch processing.  So the next message should not come off the queue until the previous one has been completed

                 

                 

                We have no control over that. We don't know when you finished/started your processing.

                It's up to you how you make the calls to the consumer, or how you implement the listener method.

                 

                 

                If you start a new thread from your consume method and ask HornetQ to send you a new message.. you are telling HornetQ that you are ready for another message. And that's how it should be.

                • 5. Re: Guaranteed Message Sequence
                  ohughes

                  Perfect, this is what I was worried about, but even if in the MDB situation, it is guaranteed to go to the exact same thread, then the ordering of the message's is guaranteed,  thanks.

                  • 6. Re: Guaranteed Message Sequence
                    clebert.suconic

                    Even if you have multiple instances on the MDB (minSession=X), the ResourceAdapter will have one session/internalConsumer for each instance. If you use message-grouping, all the messages will be sent to the same consumer what will guarantee ordering.

                     

                    The thread may be different (as there's a thread pool) but the consumer will be the same. I.e ordering will be guaranteed.