RabbitMQ and Message Queues
- What is a Message Queue?
A form of service to service asynchronous communications.
First of all, what is synchronous comms — Service A is somewhat coupled to Service B
Asynchronous Comms — Service A sends a request and continue with its life and is not directly coupled with Service B. This is achieved using a message queue and this is where RabbitMQ comes in. A message queue can decouple these services.
Service A puts a message into the queue and Service B pick up the message from the queue.
RabbitMQ is the most widely used open source Message Broker.
Message queues can also help in cases where we can generate messages way faster than we can consume the messages. It allows us to scale up the backend consumers to cater for the need of processing a ton of messages.
Delivery acknowledgement —
If Service B is down, the D/A feature of RabbitMQ will expect an acknowledgement from Service B. And if it does not get it, RabbitMQ will automatically put the message back to the queue for another consumer to pick up. This adds resilience to message queues.