Java Client: How to set ttl (seconds) when creating a queue


I am trying to find a way of how to set a ttl property in seconds when creating a new queue via jms. Currently I'm using the EndpointProperties which provides only the option to respect the ttl (I guess that can come as a value in headers from the messages). By default when a queue is created and the respect ttl option is set to true, it sets the value of Maximum TTL (sec) to 0. After reading quite of the documentation I can summarize everything in these 2 question:

  • Is there a possibility to to set the ttl value in seconds when creating a new queue via jms?
  • When setting the respect ttl option and by default Maximum TTL (sec) is set to 0, does that mean that the messages will never expire (even if they have the ttl value set in their headers)?


  • swenhelge
    swenhelge Member, Employee Posts: 77 Solace Employee

    I believe it's not possible to set the max TTL when auto-provisioning queues via JMS (as opposed to creating via Mgmt UI, CLI etc).
    However if you set TTL on the message that overrides the queue's default max TTL and messages will expire accordingly.
    @TomF will come along shortly and set us straight if I got this wrong ;-)

  • Aleksandar
    Aleksandar Member Posts: 2

    @swenhelge thank you for the answer
    I manage to test this and set the respect ttl to true while creating a new queue. As already mentioned - the default value for ttl in seconds is 0 (and it does seems that when set to 0, the message is never deleted).
    Also I can confirm that when a message's ttl is set to some value, it expires. If not set, the message just stays there in the queue.

  • TomF
    TomF Member, Employee Posts: 406 Solace Employee

    Just a quick correction - TTLs do not over-ride each other. The first TTL to expire takes effect. So if the queue has a TTL of 3 and a message has a TTL of 4, the message will expire after 3.