In this recipe, we are going to see how to let messages expire. The recipe sources can be found at
Chapter02/Recipe01/Java/src/rmqexample in the code bundle that contains the following three executable classes:
In order to use this recipe, we need to set up the Java development environment, as indicated in the Introduction section of Chapter 1, Working with AMQP.
The core of this example is in the
Producer.java file. To produce messages that expire with a given Time-To-Live (TTL), we have to perform the following steps: