developers

    Forum Stats

  • 3,873,621 Users
  • 2,266,619 Discussions
  • 7,911,594 Comments

Discussions

Question about JMSExpiration

Ogroef-Oracle
Ogroef-Oracle Member Posts: 49 Employee
edited Mar 2, 2012 7:06AM in Java Message Service (JMS)
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
Tagged:

Best Answer

  • Nigel Deakin-Oracle
    Nigel Deakin-Oracle Member Posts: 115
    Answer ✓
    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

Answers

  • Nigel Deakin-Oracle
    Nigel Deakin-Oracle Member Posts: 115
    Answer ✓
    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
  • Ogroef-Oracle
    Ogroef-Oracle Member Posts: 49 Employee
    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
This discussion has been closed.
developers