RabbitMq Installation
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
https://github.com/rabbitmq/chocolatey-package
Overview
By default, RabbitMq listens to port 5672 RabbitMq server.
Related Terms
Queue
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.
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.
Connection
In order for a user to work with RabbitMQ, it should 1st initialize a connection.
Routing Key
The producer will specify a routing key along with the message to tell the exchange in which queue this message will go.
Binding
It is a connection between queue and exchange.
Binding Key
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
- Fannout
It ignores the routing key and sends messages to all known queues. - Topic
It allows partial matching of the routing key. - Header
In this message, a header is used instead of a routing key. - Default
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.