2 Replies Latest reply: Mar 2, 2012 6:06 AM by Ogroef-Oracle RSS

    Question about JMSExpiration

    Ogroef-Oracle
      At my customer we are sending messages to Topics by using the 'javax.jms'-library and everything goes fine except for the content of the 'JMSExpiration'-field.

      All the documentation that I read on how to set this field (in milliseconds) is telling me that when I use the 'Publish'-method from the 'TopicPublisher'-class it will make the sum of the 'TimeToLive'-parameter and the moment that message is send by the Pubblisher.

      Example:
      TimeToLive parameter: 5000 ms (5sec)
      Publisher send time: X

      Result:
      When message is consumed by other party the 'JMSExpiration'-filed is holding x+5000, while my customer is asking to have only 5000 in the JSExpiration.

      Is there any way how that I can achieve this?
      Any comments are appreciated
      Also when it is not possible I would like to know (Just for me to know that I read the documentation well) !

      Kind Regards
      Olivier De Groef
        • 1. Re: Question about JMSExpiration
          Nigeldeakin-Oracle
          The behaviour of the getJMSExpiration() method on javax.jms.Message is defined in the usual place:
          http://docs.oracle.com/javaee/6/api/javax/jms/Message.html#getJMSExpiration%28%29
          It is as you describe.

          If you want to pass the time-to-live (or any other) value to the consuming client the easiest way to do this is to set a custom message property:

          before the producing client sends the message, set a message property called, say "myTTL" to whatever TTL value you are using:
          message.setLongProperty("myTTL",timeToLive);

          the consuming client can extract this value using:
          long timeToLive = message.getLongProperty("myTTL");

          Nigel
          • 2. Re: Question about JMSExpiration
            Ogroef-Oracle
            Nigel

            Thx for the achnowledgement that I understood the doc wel. The link is indeed the documentation that I have read about this.

            Also the sugested solution is one thing that I had in mind.

            Kind Regards
            Olivier