The lifetime of messages and destinations is controlled by the time-to-live (ttl), which refers to the time, in milliseconds, that is applied to both the message, and the destination that the client is subscribed to.


Time-to-live for messages is specified on the client.send(...) method call, while the time-to-live for destinations is specified on both the client.subscribe(...) method call, and the client.unsubscribe(...) method call:

  • On the client.send(...) method call, the default time-to-live applied to a message is 7 days (604800000 milliseconds). The maximum ttl value that can be applied is 30 days.
  • On the client.subscribe(...) method call, the default time-to-live applied to a destination is 0. If the destination already exists, this value will replace any previous value. Time-to-live starts counting down when there are no instances of a client subscribed to a destination, and it is reset each time a new instance of the client subscribes to the destination:
    • When a client connects to a private destination whose ttl is counting down, the time-to-live is reset to match the value of the connecting client.
    • When a client connects to a shared destination whose ttl is counting down, the time-to-live is reset to match the value of the most recent connecting client. Any member of the share can reset the ttl value of a shared destination.

    When time-to-live counts down to zero, MQ Light deletes the destination by discarding any messages held at the destination and not storing any new messages. Specifying a ttl of 0 will result in the destination being deleted as soon as there are no clients subscribed to it. The maximum ttl value that can be applied is 30 days.

  • On the client.unsubscribe(...) method call, when ttl is not specified, the time-to-live on the destination will not change. When specified, the only valid value is 0.

Join The Discussion

Your email address will not be published.