3 Replies Latest reply on May 23, 2011 3:03 AM by Sergiu Pienar

    Discarding redelivered messages

    Sergiu Pienar Expert



      I've got a scenario in which I raise a EJBException on a transaction that sends a message, thus the message being ignored by my app.

      On server restart the message is redelivered(which according to the documentation is correct).

      What can I do if I do not want this redelivery to happen ?(except of putting an expiry timer on the message).



        • 1. Discarding redelivered messages
          Clebert Suconic Master

          Max Redelivery and DeadLetterAddress (AKA DLQ). Look for it at the manual.

          • 2. Re: Discarding redelivered messages
            Sergiu Pienar Expert

            Hi Clebert,


            Thx for the response.I know about the DLA and maxRedeliveryAttempts ... but they do not apply to my scenario.

            I have maxRedeliveryAttempts set to 3.

            The flow is the following :


            1. start transaction

            2. send JMS message

            3. transaction.rollBack


            In this case the sent JMS message should never be delivered and it should be discarded.

            Unfortunately we observed that indeed message is not processed as long as JBoss is running, but somehow, at JBoss restart, this message is processed.


            Where is this JMS messages stored till JBoss restart and why hornetq doesn't observe that it is a discarded message?


            I do not want the message to be redelivered when I restart my server because the context in which the message was sent isn't valid anymore and if my message gets reprocessed it will trigger some actions that will not be consistent within the current scenario.


            Does the message has some sort of a flag set on it when it is involved on a transaction that is rolled-back so I can treat it in a special manner ?


            Message was edited by: Sergiu Pienar


            Message was edited by: Sergiu Pienar

            • 3. Re: Discarding redelivered messages
              Sergiu Pienar Expert

              I have to do Mea Culpa as I tested in a wrong scenario.