Working with message routing using direct exchanges
In this recipe we are going to see how to select a subset of messages to be consumed, routing them only to the AMQP queues of interest and ignoring all the others.
A typical use case is implementing a chat, where each queue represents a user.
We can find the relative example in the book examples directory at:
To use this recipe we need to set up the Java development environment as indicated in the Introduction section.
How to do it…
We are going to show how to implement both the producer and the consumer, and see them in action. To implement the producer, perform the following steps:
- Declare a direct exchange: