Installation on Linux machine
- Update the package list
sudo apt-get update -y
- Install prerequisite in most cases
sudo apt-get install curl gnupg -y
- Install RabbitMq
sudo apt-get install -y rabbitmq-server
- Start RabbitMq
sudo systemctl start rabbitmq-server
RabbitMq Installation on the windows machine
- Install via chocolatey
choco install rabbitmq
- Chocolatey(RabbitMq package) is open source and available on git
By default, RabbitMq listens to port 5672 RabbitMq server.
Everything/Messages go to queue for further processing.
Whatever message produced by the publisher goes to the queue and from the queue, the consumer consumes.
The publisher doesn’t contact the queue directly. It needs an Exchange.
It is an additional layer to implement the concept of abstraction. The producer doesn’t know further processing of the messages.
Also if we have multiple queues, the exchange is responsible for routing the messages to the specific queue.
In order for a user to work with RabbitMQ, it should 1st initialize a connection.
The producer will specify a routing key along with the message to tell the exchange in which queue this message will go.
It is a connection between queue and exchange.
Each binding has a unique binding key, to avoid any confusion for the target queue.
Let’s say we have two queues one with binding key white and the other with black.
If the producer specifies white – the message will go to the first queue and it specifies black message will go to the 2nd queue.
Note – Exchange will send message to the queue where
Routing key = Binding key
Types of Exchange
It ignores the routing key and sends messages to all known queues.
It allows partial matching of the routing key.
In this message, a header is used instead of a routing key.
It is also known as a nameless exchange. It is the ideal exchange. Which checks if the routing key is equal to a binding key or not.
Leave A Comment