RabbitMQ Fanout Exchange Explained

RabbitMQ has some built-in exchanges and some that are enabled via a plugin. Fanout exchange is built in to RabbitMQ and can be used to route one message to multiple users.Use a fanout exchange when you wish to broadcast data to multiple places.

What is RabbitMQ Fanout Exchange?

The fanout exchange will route published messages to any queues bound to it without any conditions and no balancing between the queues. You shouldn’t even specify a binding key, and, if you do, the exchange will just ignore it. Furthermore, there is no limit to how many queues you can bind to the exchange.

When to use RabbitMQ Fanout Exchange

As an example, say you have a website that sells shoes . When there is a sale, you want to notify all your customers. The problem is that some customers wish to have the information over email while others prefer to receive messages over SMS, and others still like it sent over a social media network.

You have three different workers with different skills; one knows how to send an email, one can send SMS, and one sends messages over the social network. They are all bound to a fanout exchange in RabbitMQ. All you need to do is to write your text about the sale and send that message to the fanout exchange. Queues bound to that exchange will get the message and send it out to your customers in their preferred way.

RabbitMQ Fanout Exchange Fact Box

Exchange

An exchange is responsible for routing the messages to the different queues with the help of attributes, bindings, and routing keys.

Binding

A binding is a "link" that you set up to bind a queue to an exchange.

Routing key

The routing key is a message attribute. The exchange might look at this key when deciding how to route the message to queues (depending on exchange type). The routing key is like an address for the message.

Try out RabbitMQ at CloudAMQP

Don’t forget that you can create a free RabbitMQ instance at CloudAMQP and begin experimenting with exchanges by taking a few minutes to sign up here: https://customer.cloudamqp.com/signup

Please email us at contact@cloudamqp.com if you have any suggestions, questions or feedback.

CloudAMQP - industry leading RabbitMQ as a service

Start your managed cluster today. CloudAMQP is 100% free to try.

13,000+ users including these smart companies