Embedding message destinations within messages

In this example, we show how to use a single publish to send a message with multiple routing keys. The standard AMQP doesn't provide this feature but luckily, RabbitMQ does so using a message properties header. This extension is called sender-selected distribution.

The behavior of the extension is similar to e-mail logics. It uses Carbon Copy (CC) and Blind Carbon Copy (BCC). This is the reason you will find CC and BCC consumers in the source code, located in Chapter02/Recipe09/Java/src/rmqexample:

  • Producer.java
  • Consumer.java
  • StatsConsumer.java
  • CCStatsConsumer.java
  • BCCStatsConsumer.java

Getting ready

To use this recipe, we need to set up the Java development environment as indicated in the Introduction

Get RabbitMQ Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.