3 Replies Latest reply on May 29, 2003 4:29 AM by adrian.brock

    Does JMS messages time out?

      I have been trying to get some messages to expire but nothing I try seems to work.

      Using JBoss 3.0.7.
      Running the JBoss server and client app on the same box.
      Using MySQL for message persistance.

      My app running under JBoss sends 5 TextMessages to a topic. I set the time to live and JMSExpire fields to a value like 10 seconds. I can see the messages in the db.

      After about a minute or so, I fire up the client app that receives these messages. I would expect that the client does not receive any messages because they are supposed to be expired. However, my client app always receives all the messages.

      How is this supposed to work?

      Here are related posts:
      http://jboss.org/thread.jsp?forum=48&thread=4345&message=327715&q=expiration#327715
      http://jboss.org/thread.jsp?forum=48&thread=4273&message=316498&q=expiration#316498
      http://jboss.org/thread.jsp?forum=48&thread=3743&message=251292&q=expiration#251292
      http://jboss.org/thread.jsp?forum=48&thread=4447&message=334105&q=expiration#334105

        • 1. Re: Does JMS messages time out?

          This has recently been fixed for 3.2 in CVS.

          3.0 still only checks the expiration when it
          attempts delivery to the client.

          If we get some good feedback we can backport
          the fix to 3.0

          How are you setting the time-to-live?
          You should be setting on the publish operation
          or setting a default on the publisher.

          The following doesn't work as you might expect,
          read the javadocs for publish(msg)

          TextMessage msg = session.createTextMessage();
          msg.setTimeToLive(whatever);
          publisher.publish(msg);

          Regards,
          Adrian

          • 2. Re: Does JMS messages time out?

            Thanks for the info.

            Yes, that is exactly how I am setting the TOL value.

            If I really need to implement this feature I can do some sort of work around for now.

            Thanks

            • 3. Re: Does JMS messages time out?

              The correct way is:

              TextMessage msg = session.createTextMessage();
              publisher.publish(msg, DeliveryMode.PERSISTENT, 4, whatever);

              or

              publisher.setTimeToLive(whatever);
              TextMessage msg = session.createTextMessage();
              publisher.publish(msg);

              Regards,
              Adrian