5 Replies Latest reply on Nov 20, 2003 1:01 AM by Elias Ross

    time control on retried messages

    Skely Newbie

      Hi Guys,

      In my Message Driven Bean, I rollback the transaction using context.setRollbackOnly() and this ensures that JMS message is resent to me. JBoss resends the message very quickly. I want to control the time in which JBoss tries to resend the message. Is there a way to control this timelimit.

      Thanks in advance,
      Magesh

        • 1. Re: time control on retried messages
          Bernd Zeitler Expert

          It is configured with your invoker-proxy-binding configuration for your MDB (in standardjboss.xml or jboss.xml of your bean):
          [pre]


          [/pre]

          Greetings,
          Frito

          • 2. Re: time control on retried messages
            Elias Ross Master


            There are a couple ways of doing this.

            1. Easy: Simply call Thread.sleep if the incoming message is a redelivered message. Call getJMSRedelivered() to check for this. (In 3.2.1 there is a vendor-specific property that says how many times the message was redelivered as well, so you can have incremental delay here.)

            2. Medium: In JBoss 3.2.1, set the redelivery delay property on the message before it is sent. The property is named "JMS_JBOSS_REDELIVERY_DELAY", refer to SpyMessage.java for details.

            3. Medium: In 3.2.1 you can simply requeue a new message with a scheduled delivery time. Copy the message to a new JMS message and requeue it. (You lose the redelivered flag.) One obvious problem is you can't rollback container the transaction.

            3. Harder: Modify JBoss. Add a method to MessageDrivenContext which takes a delay value, so calling "mdc.rollback(123)" will rollback the transaction and message, and have the message get rescheduled to be delivered in 123 milliseconds.

            • 3. Re: time control on retried messages
              Elias Ross Master

              I wrote the delivery schedule features; they may not be in 3.2.1, it will be in the official 3.2.2. 3.2.2RC1 has it, I believe.

              • 4. Re: time control on retried messages
                Rudolf Frank Newbie

                How can I use the delivery schedule features? I couldn't find it in 3.2.2.

                • 5. Re: time control on retried messages
                  Elias Ross Master


                  They are done by setting message properties.

                  Example:

                  Message m = ...
                  m.setLongProperty("JMS_JBOSS_REDELIVERY_DELAY", 1000);

                  (delays the redelivery for 1 second)