6 Replies Latest reply on Feb 17, 2011 10:11 AM by ataylor

    HornetQ MDB timeout

    check1check1

      JBoss 5.1 with HornetQ

      I need a MDB to rollback if it cannot process a message in 30 seconds. Is this possible ?

      The

      @TransactionTimeout(30000) annotation doesn't seem to work.

      I use it along with:

      @TransactionManagement(value = TransactionManagementType.CONTAINER)

      @TransactionAttribute(value = TransactionAttributeType.REQUIRED)

      Current behavior is that if 5 minutes pass, JMS rolls back the transaction. However, this way the code is executed multiple times: for the first delivery and for each redelivery as JMS does know that the transactions has been canceled.

      Could this be coped somehow ? Ideally I would like the MDB to rollback before JMS cancels the transaction.

        • 1. HornetQ MDB timeout
          ataylor

          when you say you want the MDB to rol, back, do you mean that you wantthe transaction manager to roll back the transaction after n milliseconds?

           

          As far as i can see the correct behaviour is happening, HornetQ delivers the message to the MDB as part of the transaction and the when the transaction manager rolls it back HornetQ puts it back on the queue, is this not what you want to happen?

          • 2. HornetQ MDB timeout
            ataylor

            just a note, this will happen how ever many times redeliveryAttempts is set to on the queue

            • 3. Re: HornetQ MDB timeout
              check1check1

              Here is the scenario:

               

              1. We have a MDB instance;

              2. The MDB receives messages from queue Q1.

              3. We publish a message.

              4. MDB1 tries to process it, but we put a 1 hour sleep to simulate a long process

              5. HornetQ cancels the transaction

              6. After one hour, the message is proceesed

              7. However, HornetQ redelivers the message as it knows it hasn't been processed (tx canceled)

              8. ... this goes on and on, as the redelivery count is always reset to "1"

               

              Please consider the possibilities when there are multiple MDB instances

              • 4. Re: HornetQ MDB timeout
                ataylor

                that exactly how it should work and does. however its not HornetQ that cancels the tx its the transaction manager. if you are saying that you want the MDB to stop executing the onMessage method of the MDB then this has nothing really to do with a transaction, the tx only deals with XA resources JMS, databses etc not the mdb itself. The code in the MDB is application code and its up to the Application developer to cope with any issues they may have.

                 

                If you tell me what you are trying to acheive then maybe i can help

                • 5. HornetQ MDB timeout
                  check1check1

                  So how could one cope with this case, when a message could be processed over and over again ?

                  Implement his own message processing tracking mechanism ?

                  I believe this is something generic, and not a feature each developer should handle on his own.

                   

                  However, this rather looks like an EJB issue - i.e. not timing out.

                  • 6. HornetQ MDB timeout
                    ataylor

                    well this is handles by setting redelivery attempts like i said earlier. However i seemed to get the feeling that you want the MDB itself to stop executing, or am i misunderstanding you?