What is RabbitMQ?

Overview

RabbitMQ is a message queuing system also known as a message broker or queue manager. it is a software where queues can be defined, and applications may connect and transfer a message onto it. Message queues enable asynchronous communication, which means that other applications that are producing and consuming messages interact with the queue instead of communicating directly with each other.

Two different applications written in two different programming languages can communicate with each other by using RabbitMq as a middleman.   

The message broker stores the messages until a receiving application connects and consumes a message off the queue. The receiving application then appropriately processes the message. A message producer adds messages to a queue without having to wait for them to be processed.

message-queue

A message can include any information, it could be a simple text message or complex task information.

When To Use RabbitMQ

As a use case let suppose we need to generate a large report and send it to a user.

1. The user make a request to create request to the web application.
2. The web application (the producer) sends a message to RabbitMQ that includes
data from the request, such as name and email.
3. An exchange accepts the messages from a producer application and routes them
to correct message queues.
4. The PDF processor (the consumer) receives the job message from the queue and
starts the processing of the PDF.

Conclusion

  • A message broker can act as a middleman for various services.
  • A broker can be used to reduce loads and delivery times by web application servers.
  • A task that would generally take a lot of time to process can be delegated to a third party whose only job is to perform them by using RabbitMQ as a middleman.
  • Requests can be created in one programming language and handled in another programming language, as the two applications only communicate through the messages they are sending to each other.