RabbitMQ In Event-Driven Communication Between Microservices


A microservice architecture now a days very import for businesses to scale and maintain their application. Development, testing, and updates of individual microservices can be done continuously and independently. Compared to more monolithic design structures, microservices offer more agile approach to software development and maintenance.

  • Remote Procedure Calls (RPC)
  • Brokers (eg: RabbitMQ , ActiveMQ , Kafka)

RabbitMQ VS Kafka

Apache Kafka and RabbitMQ are two open-source message broker and commercially-supported pub/sub asynchronous processing systems.


RabbitMQ is one of the most widely used open-source message brokers. It is lightweight , easy to used and support most of the technologies like Kubernetes ,Docker, languages such as .NET ,Java, Python or Go. It also offers plugins for monitoring, managing or authentication.

RabbitMQ Architecture

RabbitMQ was originally based on the Advanced Message Queuing Protocol (AMQP).In the RabbitMQ architecture main components are Producer application ,Exchange ,Queue and Consumer application.


Producing means nothing more than sending a messages .A producer pushes messages to exchanges.


Exchange is basically a routing rule for the messages. Messages are not published directly to a queue; instead, the producer sends messages to an exchange. An exchange is responsible for routing the messages to different queues with the help of bindings and routing keys. A binding is a link between a queue and an exchange. There are four types of Exchanges Direct ,Fanout ,Topic and Header exchange .

  • Fanout: A fanout exchange routes messages to all of the queues bound to it. Ex: When the user create an appointment ,It will route to all the queues ,that means send an email to patient ,doctor and hospital administration.
  • Topic: The topic exchange does a wildcard match between the routing key and the routing pattern specified in the binding. Ex: If the user cancel the appointment ,system only needs to send an email to doctor and hospital administration.so message push to doctor-notification ,admin-notification.
  • Headers: Headers exchanges use the message header attributes for routing.


A queue is a line of things waiting to be handled, starting at the beginning of the line and processing it in sequential order.


Consumer also known as a subscriber. It reads messages from the queues and send the ack to the RabbitMQ .


Using RabbitMQ, you can avoid direct HTTP calls between services and remove tight coupling of core microservices. This will help you in scaling your microservices at a higher level and add failover mechanisms between microservices.

Assistant Lead Engineer ( C# .net Core, Angular + Azure DevOps +AWS+ Kubernetes + Docker + microservices )