Skip to main content

Command Palette

Search for a command to run...

Fanout exchange in RabbitMQ

Published
1 min read
Fanout exchange in RabbitMQ
H

Experienced Full Stack Java developer. Have Strong Experience in JSP/Servlet, JSF, Jasper Report, Spring Framework, hibernate, Angular 5+, Microservices. Experienced in Front-end technologies such as HTML, CSS, JavaScript, angular 6+, AJAX, JSON, and XML. Strong Hands-on experience on working with Reactive Forms to build form-based application in Angular 6+.

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.

More from this blog

Java Blogs By Hemant: Expert Insights, Tips, and Tutorials for Java Developers

42 posts

Welcome to Java Blogs By Hemant! I'm Hemant, an IT professional having years of experience as Java Full Stack Developer.