Not Delivered Semantics
What happens to messages that are not selected for delivery to the consumer by its message selector? This depends on the message model used. For the publish-and-subscribe model, the messages are not delivered to that subscriber; they are, however, delivered to other pub/sub subscribers. This is true for both nondurable and durable subscriptions. For the point-to-point model, any messages that are not selected by the consumer are not visible to that consumer. They are, however, visible to other point-to-point consumers.
Because messages may not be delivered to consumers based on message filtering, it is important to make sure that all messages produced by a sender or publisher have a corresponding expiration associated with them. By default, messages are set never to expire. This means that if a message is filtered out and not delivered to a consumer, it will reside in the queue forever. By setting the message time to live option, you can control how long the message stays on the queue if it is not delivered.
The JMSExpiration header
property contains a timestamp indicating when a message is set to
expire. The JMS provider will constantly check the queue or topic (i.e.,
subscribers) for any messages set to expire and will automatically
remove the message when the message is set to expire. The JMSExpiration header property is set by the JMS provider and is calculated by adding the time to live (in milliseconds) specified by the JMS developer to the timestamp ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access