5 Replies Latest reply on Nov 20, 2009 10:08 AM by timfox

    Orderer redelivery of messages

    egomet

      Hi guys!

      We have an application in production with a requirement about the order of messages sent to queues: the queue must maintain the delevery order also in case of failure and redelivery. The version of JBoss that we are using (3.x) did not provide the "ordered redelivery" of messages: if the client sends the messages "1", "2" and "3" in this sequence, and the message "2" fails, we are not assured that the container tries to redeliver the message "2" the specified number of times (10 by default) and then picks the message "3" up. The behavior that we experimented is that
      the redelivered message is put in the queue without maintaining the initial order, so it is possible that the receiver will pick up the message "3" before the redelivered message "2".

      We have solved the problem by writing our own JMSContainerInvoker, configured as a "Singleton Message Driven Bean" and deployed in the JBoss server.

      My question is: "does JBoss Messaging 1.2X provide the ordered redelivery of incoming messages?"

      I made some test by using JBoss 4.0.5GA and JBoss Messaging 1.2.0.sp1, without the custom invoker, configuring the receiving MDB as a Singleton: it seems to work (i.e. to implement the ordered redelivery), but I'm still looking in the source code for confirmation.

      Could you confirm the observed behavior (ordered redelivery implemented) or maybe provide a counter-example that shows a case in which redelivery does not maintaing the arrival order of messeges?

      Thank you for the help.
      Marco

        • 1. Re: Orderer redelivery of messages
          egomet

          A small change in what said before: the application is currently in production with JBoss 4.0.2 and not 3.x.

          • 2. Re: Orderer redelivery of messages
            timfox

            In the general case ordered redelivery is very hard to guarantee.

            Consider a queue with several transactional sessions and consumers consuming from it.

            The consumers are consuming at different rates, and every so often they rollback (or fail). When they rollback, their unacknowledged messages go back on the queue.

            The order they go back on the queue is determined by the order in which they rollback (or fail). So you can see its not deterministic.

            For the special case of having only one session and consumer on a particular queue, then, yes, JBoss Messaging will try to redeliver the messages in the same order as they were first delivered, but we don't provide any hard guarantees of this over and above the JMS spec.

            • 3. Re: Orderer redelivery of messages
              timfox

              If you are using MDBs the situation is further complicated, since the app server can obtain several messages from the underlying JMS provider in one go before forwarding to the MDB.

              Probably the only reason you are seeing ordered redelivery with MDBs is that JBM does local delivery on rollback (i.e. does not force a NACK like JBoss MQ). I wouldn't guarantee this behaviour stays for ever.

              So the bottom line is, no we don't guarantee ordered redelivery, although you may see something that looks like ordered redelivery under some circumstances.

              • 4. Re: Orderer redelivery of messages

                Hi Tim,

                I'm a collegue of Egomet (my name is Mirco) and I'm working on the same task of Egomet.

                In the next weeks I will study how to patch JBoss/HornetQ to obtain the ordered redelivery using a special configuration to avoid multithreading problems.

                If you are interested to our solution I will send the patch (using the right procedure) for the commit.

                We found a solution using JBoss 4.0.2 but now we want to upgrade the AS so I would like to insert it in the head line of the sources.

                Thanks for your time.

                Regards

                Mirco

                • 5. Re: Orderer redelivery of messages
                  timfox

                  If you're talking about HornetQ, you're in the wrong forum.