7 Replies Latest reply on Jul 23, 2003 6:47 AM by adrian.brock

    Redeliver messages

    nmartins

      Hi all,

      I send a message to a queue and it isn't acknowledge. I would like to know why this message isn't redeliver unless jboss is restarted.

      Do I need to config something? If yes, is it possible to configure timeout period.

      I'am using jboss 3.0.7.

      Reguards,
      Nuno Martins

        • 1. Re: Redeliver messages

          Are you using client acknowledge?
          Did you close the session? That will nack
          unacknowledged messages, alternatively dropping
          the connection will as well.

          Regards,
          Adrian

          • 2. Re: Redeliver messages
            nmartins

            Hi,

            I'am using client acknowledge.

            My application will be like a deamon. Connection and session will be closed when this application ends.

            Do you lnow if there is a way to config jboss to redeliver messages without close connection or session?

            Reguards,
            Nuno Martins

            • 3. Re: Redeliver messages

              session.recover()
              will redeliver unacknowledged messages

              Regards,
              Adrian

              • 4. Re: Redeliver messages
                r_kumar

                hi,

                I am facing a problem in Redelivery of Messages under the following scenario,

                An application has subscribed (to receive messages form) to a "Topic" with the acknowledgment option set to as "Client Acknowledgment". This subscriber will perform some business operation and on the successful completion of the same the received message will be acknowledged. Suppose while performing the operation exception is thrown then, the message will not be acknowledged in the assumption that the message will be redelivered to the subscriber. But the message is not getting redelivered. JMS javadocs states that the JMS Provider will redeliver the message to the subscriber. The Topic i am using is non-durable and the Session and Connection created are not closed.

                If the above observation is correct, then what should (configuration chages) be done to get the unacknowledged messages from the Topic?

                As stated in your mail should the application call the "session.recover()" to get the unacknowledged messages ?
                Why at all the application should do this, ideally JMS Provider should take care of redelivering the messages (unacknowledged) to their Subscribers ?

                JBoss version is : 3.0.0

                Please let me know your comments on the same.

                Thanks,
                Pravin.

                • 5. Re: Redeliver messages

                  "Client acknowledge" will only ack/nack under your control
                  not the JMS provider except when it nacks unacknowledged
                  messages at session/connection close.

                  If you are using a MessageListener, it is not
                  recommended to leak a RuntimeException from onMessage().
                  It is implementation specific how many times such
                  a message is redelivered. In JBoss's case the message
                  is redelivered *zero* times.

                  You should use:
                  public void onMessage(Message m)
                  {
                  try
                  {
                  // Do work

                  // Done
                  m.acknowledge();
                  }
                  catch (Throwable t)
                  {
                  // Handle the problem:
                  // e.g. 1 redeliver
                  session.recover();
                  // e.g. 2 save the message somewhere and acknowledge
                  recordFailure(m, t);
                  m.acknowledge();
                  }
                  }

                  For a non-durable topic subscription, closing the
                  session/connection will delete the subscription so it won't be redelivered anyway.

                  I would recommend you upgrade, there
                  are lots of memory leaks in the topic processing before
                  jboss-3.0.4 and some good performance improvements
                  and bug fixes in jboss-3.0.7/jboss-3.2.x

                  Regards,
                  Adrian

                  • 6. Re: Redeliver messages
                    r_kumar

                    Hi,

                    I tried doing the way suggested by you. When any exception occurs in the MessageListener while processing the message , i called the " session.recover() ". But the call to session to recover resulted in throwing a IllegalStateException. The trace for the same is given below ,

                    javax.jms.IllegalStateException: The session is not transacted
                    2003-07-23 17:25:15,485 ERROR [STDERR] at org.jboss.mq.SpySession.rollback(SpySession.java:353)2003-07-23 17:25:15,486 ERROR [STDERR] at org.jboss.mq.SpySession.recover(SpySession.java:388)
                    2003-07-23 17:25:15,487 ERROR [STDERR] at example.SampleSender.onMessage(SampleSender.java:117)2003-07-23 17:25:15,487 ERROR [STDERR] at org.jboss.mq.SpyMessageConsumer.run(SpyMessageConsumer.java:485)

                    The session for both Message Producer and Message Consumer are created with transacted attribute as "false".

                    JBoss version is : 3.0.0

                    The exception message that is given states that the session is not transacted , but according to JMS specification the acknowledgment mode is valid only for non-transacted sessions. But here it seems that with "Client_Acknowledgment" option it needs the session to be transacted !!!! . Does this not violate the JMS Specification ?

                    Please let me know your views in this regard.

                    Thanks,
                    Pravin

                    • 7. Re: Redeliver messages

                      That was a bug in jboss-3.0.0 (a typo in the code)

                      Regards,
                      Adrian