O'Reilly logo

RabbitMQ Cookbook by Sigismondo Boschi, Gabriele Santomaggio

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

Chapter01/Recipe07/Java_7/src/rmqexample/direct

Getting ready

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:

  1. Declare a direct exchange:
    channel.exchangeDeclare(exchangeName, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required