In this example, we show how to manage expired or rejected messages using dead letter exchanges. The dead letter exchange is a normal exchange where dead messages are redirected; if not specified, dead messages are just dropped by the broker.
You can find the source in
Chapter02/Recipe04/Java/src/rmqexample, where you can find the following files:
To try expired messages, you can use the first code alone that publishes messages with a given TTL, as shown in the How to let messages expire on specific queues recipe.
Once started, the consumer of the example will not allow the messages to expire but will reject all the messages, leading to dead messages as well.
To use this ...