Fanout exchange in RabbitMQ

Unlike Direct Exchange, Fanout exchange routes the messages to all the queues bound to it.

That's why it doesn't need a routing key

How to Create Fanout Exchange ?

  1. Login to RabbitMQ web UI.

  2. Go to "Exchanges" and click on "Add new exchange"

  3. Provide exchange name and from drop down select "fanout"

  4. click on "Add Exchange" to save it.

Then go to list of exchanges and click on your fanout exchange to bind it with queues.

provide queue name you want to bind. This time you don't have to provide routing key.

Now lets see in practical. I have bounded my "fanout-exchange" to my "xml" and "excel" queue.

let me publish my message.

After publishing, we have message in both the Queue

lets start the consumer.

  • started the excel consumer and it got the message.

  • started the xml consumer and it also got the message.

This is all about fanout exchange, in the next blog we will learn more about RabbitMQ.