JMS Standards allow setting Time To Live (TTL) on a message being sent to a destination. The JMS provider considers this message valid up to the period specified in the TTL. Once the TTL period elapses, the message expires, ceases to be available on the destination and fails to be delivered.
Point of Checking of Message Expiry
The server adds the current specified time of TTL to the current time and obtains the expiry time. This is done when the message fist enters the server. The server checks for expiry when attempting to deliver it to a consumer. If expired, the message is ignored.
Since expiry is checked just before delivering the message to a consumer; if there is no active consumer, expired messages might continue to consume server resources (disk or memory space). To optimize performance and server resources, the server can be configured to check expired messages in all queues periodically. To enable this, set the value of the flag DbCleanupEnabled to true. (By default, it is set to false.) The frequency with which the server checks for expired messages is configured through the parameter CleanupInterval. (By default set to 10 minutes.)
On Detection of an Expired Message
Once the server detects an expired message, it deletes this message from the destination. Since this deletion is done automatically, a copy of the message can be:
- pushed into the Dead Message Queue.
published to an Admin Topic.
Dead Message Queue
Dead Message Queue is a special system queue with the name SYSTEM_DEADMESSAGES_QUEUE created for storing copies of messages that expire in any of the server destinations. Any client applications can browse or receive messages from this queue using normal JMS semantics.