What is RabbitMQ?

Technoid Editor
Technoid Community
Published in
4 min readMar 8, 2023

RabbitMQ is basically a message broker which is a message queuing software. In other words, it’s software where queues are established and apps connect to transfer messages.

What is a message broker?

A message broker is a piece of software that enables information exchange and communication between applications, systems, and services. By converting messages between authorized communications protocols, the message broker achieves this. This enables interdependent services to directly “communicate” with one another, even if they were developed on other platforms or in different programming languages.

Message brokers are software components that are part of messaging middleware or message-oriented middleware (MOM) systems. It allows users to handle data flow between the application’s components and focus on the application’s core functionality. It acts as a distributed communication layer, which allows different platforms to connect with each other.

Message brokers sometimes rely on a component called a message queue to offer reliable message storage and promised delivery. The message queue stores and arranges messages until the consuming applications can consume them. Messages in a message queue are saved in the precise sequence in which they were broadcast and remain in the queue until delivery is verified.

Types of routing in RabbitMQ

Direct : route messages to all queues that have an exact match for a routing key.

Fanout : exchange can broadcast a message to any queues that are attached to it. Doesn’t consider about the routing key or the pattern.

Topics : technique is similar to direct in that it employs a routing key, but it also supports wildcard and precise matching. Messages are routed to one or more queues if a message routing key and this pattern match.

Headers : routes messages based on arguments containing headers and optional values. Same as topic but consider headers instead of the routing key.

When and why should you use RabbitMQ?

RabbitMQ is a reliable, mature general-purpose message broker that supports a variety of protocols including AMQP, MQTT, STOMP, and others. RabbitMQ is capable of handling heavy throughput. It is often used to perform background tasks or to act as a messaging broker between microservices. The ability of RabbitMQ to support different protocols means that it can be used in many different scenarios.

Messages are held in RabbitMQ until a receiving application connects and gets a message from the queue. The client can ack (acknowledge) the message when it gets it or after it has thoroughly received it. In any case, the message is removed from the queue after it has been acknowledged.

Assume there are two different applications that have their own features and processes. And integrating them together requires a middleware that can handle the connection of both platforms to work seamlessly, without any data losses in the processes. Here comes the point where we can use RabbitMQ to overcome these problems.

For example: There’s an application which do create classes by tutors so at the same time in the other application which is written from a different language needs to create a course so to sync up the class creation process with the course creation process which needs to listen to class creation events.

This sync-up requires calling multiple REST API Endpoints (a different Endpoint for each task), Mapping those system-specific tasks accordingly, Providing required data correctly, and executing them Sequentially.

So every task depends on the result of the previously executed tasks. So here class creation Message Producers emit new messages to a specific RabbitMQ Message Queue based on different events happening in class creation and the Message Consumers in the course creation listen to those messages and handle those tasks accordingly.

Author

Credits for this article must go to the following author for contributing their time, effort, and knowledge to the Technoid Community.

Author: Ashini Kulatunga

--

--

Technoid Editor
Technoid Community

Uniting technoids, driving tech progress Powered by Surge Global