This article is a sequence of my previous RabbitMQ article: Unraveling RabbitMQ: How to Scale Systems with Queues. Check it out to deep dive into the concepts!
RabbitMQ is an open-source message broker that acts as the intermediary between independent and heterogeneous applications, providing systems a common way to communicate. Commonly used in Microservices Architecture, it is a software where queues are defined, to which applications connect in order to transfer messages. The queue-manager software stores the messages until a receiving application connects and takes a message off the queue.
RabbitMQ uses an implementation of Advanced Message Queuing Protocol - AMQP, which supports advanced features such as clustering and complex message routing.
What is AMQP?
AMQP (Advanced Message Queuing Protocol) is a powerful, open-standard application layer protocol for message-oriented middleware. It basically defines how a system can exchange messages. Its main purpose is to provide a standardized way for different systems to exchange messages asynchronously, regardless of the operating system, programming language, or message broker implementation being used.
The protocol defines a set of rules and capabilities that systems must follow. By implementing this specification, AMQP ensures interoperability between different vendors' messaging brokers and client applications.
Why should you use RabbitMQ?
When an application is broken down into many small, independent services, or "microservices" as called in Mircroservices Architecture, they need a way to talk to each other. There are two main ways for them to communicate:
1. Synchronous Communication
This is like calling someone on the phone.
- How it works: One microservice calls another microservice directly, then stops and waits for an immediate response.
- Example: The Request-Response pattern (like using HTTP). A service asks, "What is the price?" and waits for the answer before doing anything else.
- The Problem (Coupling): This creates a strong dependency, or coupling, between the services. If the second service is slow, busy, or completely down, the first service also stops working or slows down. It ties the services together.
- When to use it: When you absolutely need an immediate answer to proceed, like checking a user's login credentials.
2. Asynchronous Communication
This is like sending an email or a text message.
- How it works: Instead of calling the service directly, the first service sends a message (a "request") to a central Message Queue (like RabbitMQ). The sending service then immediately goes back to its own work, without waiting.
- The Role of RabbitMQ: RabbitMQ acts as this messenger. It reliably holds the message until the correct microservice is ready to pick it up, process it, and deliver the result back later.
- The Benefit (Decoupling): This allows services to be loosely coupled. If one service is busy, the messages just queue up, and the sending service doesn't even notice the delay, it keeps running smoothly. This improves resilience, scalability, and performance.
- When to use it: For tasks that can happen in the background or take time, such as processing a large payment, sending an email confirmation, or generating a report.
In summary: RabbitMQ enables Asynchronous communication, which is crucial for making microservices reliable, scalable, and independent of each other.
How does RabbitMQ work?
To understand how RabbitMQ works, check the diagram below, which illustrates the journey of a message through an example application, a PDF generation system.
The process happens in four main, simple steps:
- The Request (Start): A user on a Website Application triggers a task that should run in the background, such as asking to "Create a PDF."
- The Producer Publishes: The Website Application, acting as the PRODUCER, doesn't do the work immediately. Instead, it packages the request (including necessary data like name and email) into a message and Publishes (sends) it to RabbitMQ.
- The Routing Inside RabbitMQ:
- A component called the Exchange receives the message from the Producer.
- The Exchange's job is to act as a sorter. It uses Routing rules to ensure the message is delivered to the correct Queue (in this diagram, the Message Queue for PDF requests).
- The Queue securely holds the message, acting as a buffer until a service is available to handle it.
-
The Consumer Processes:
- A dedicated background service, called the CONSUMER (the PDF Creator Worker), constantly monitors the Queue.
- The Consumer retrieves (Consumes) the task message and begins the actual work: creating the PDF.
How to install RabbitMQ using Docker
Using Docker is the easiest and fastest way to get RabbitMQ running on your local machine. This method uses a pre-built image that includes both the RabbitMQ server and its Web Management interface, saving you the hassle of manual installation.
To start RabbitMQ with the management plugin enabled, you need to run a specific docker run command. This command sets up the container, maps the necessary ports, and specifies the RabbitMQ version you want to use.
# For RabbitMQ 3.13 specific version
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.13-management
# For RabbitMQ 3.8, specific version
# Support timeline: https://www.rabbitmq.com/versions.html
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3.8-management
-
docker run: The command to create and start a container. -
-it: Runs the container in interactive mode and allocates a pseudo-TTY, allowing you to see logs and output. -
--rm: Crucial: This automatically removes the container and its file system when it exits. This keeps your system clean. -
--name rabbitmq: Assigns the easy-to-read name rabbitmq to your container. -
-p 5672:5672: Maps the AMQP Port. This forwards the standard RabbitMQ port inside the container (5672) to the same port on your computer. This port is used by applications to send and receive messages. -
-p 15672:15672: Maps the Management Port. This forwards the port for the Web Management interface (15672) to your computer, allowing you to access the dashboard in your browser. -
rabbitmq:3.13-management: Specifies the Docker image to use. The-managementtag ensures the helpful web interface is included. (You can check the official Docker Hub for other versions likerabbitmq:latest-management).
If you want to see the server status while it's running, open a new terminal window and use this command: docker logs -f rabbitmq
After the container starts (which usually takes only a few seconds), the RabbitMQ Web Management interface will be available.
- URL: Access the dashboard at: http://localhost:15672
- Default Login: Use the default credentials:
- Username: guest
- Password: guest
On this screen, you can monitor the health of your broker, view the number of active Queues and Exchanges, manage Users, and inspect the flow and volume of messages.
Note: For security reasons, the guest/guest user can only connect from localhost (your machine) by default. For production environments or when deploying to a server, you must create a new administrator user with a strong password.
How to install RabbitMQ on Ubuntu
Installing RabbitMQ on Ubuntu requires two main steps: getting the necessary packages like Erlang (which RabbitMQ is built on) and then installing the RabbitMQ server itself. The official RabbitMQ team provides an easy-to-use package repository for this.
Important: The script below is comprehensive but relies on specific versions and repository settings that can change over time. It is best practice to always check the official RabbitMQ documentation for the absolute latest installation instructions and key fingerprints before running this on a production server.
The following script automates the entire process: installing dependencies, adding the necessary software repositories, importing the security keys, and finally installing Erlang and RabbitMQ Server.
#!/usr/bin/sh
# 1. Install necessary tools (curl, gnupg, etc.)
sudo apt-get install curl gnupg apt-transport-https -y
# 2. Import GPG keys for security verification (RabbitMQ, Erlang, and PackageCloud)
curl -1sLf "https://keys.openpgp.org/vks/v1/by-fingerprint/0A9AF2115F4687BD29803A206B73A36E6026DFCA" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/com.rabbitmq.team.gpg > /dev/null
curl -1sLf "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xf77f1eda57ebb1cc" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg > /dev/null
curl -1sLf "https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/io.packagecloud.rabbitmq.gpg > /dev/null
# 3. Add the RabbitMQ and Erlang package repositories to APT sources
sudo tee /etc/apt/sources.list.d/rabbitmq.list <<EOF
## Provides modern Erlang/OTP releases
deb [signed-by=/usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg] http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu bionic main
deb-src [signed-by=/usr/share/keyrings/net.launchpad.ppa.rabbitmq.erlang.gpg] http://ppa.launchpad.net/rabbitmq/rabbitmq-erlang/ubuntu bionic main
## Provides RabbitMQ Server
deb [signed-by=/usr/share/keyrings/io.packagecloud.rabbitmq.gpg] https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ bionic main
deb-src [signed-by=/usr/share/keyrings/io.packagecloud.rabbitmq.gpg] https://packagecloud.io/rabbitmq/rabbitmq-server/ubuntu/ bionic main
EOF
# 4. Update package lists
sudo apt-get update -y
# 5. Install Erlang and its components (required by RabbitMQ)
sudo apt-get install -y erlang-base \
erlang-asn1 erlang-crypto erlang-eldap erlang-ftp erlang-inets \
erlang-mnesia erlang-os-mon erlang-parsetools erlang-public-key \
erlang-runtime-tools erlang-snmp erlang-ssl \
erlang-syntax-tools erlang-tftp erlang-tools erlang-xmerl
# 6. Install rabbitmq-server
sudo apt-get install rabbitmq-server -y --fix-missing
The steps 1, 2 and 3, install basic tools, import the required GPG security keys, and add the official repositories (one for Erlang and one for RabbitMQ) to your system's package list.
The steps 4, 5, and 5 update the package list and install all the required Erlang components and the RabbitMQ server.
How to install RabbitMQ on RPM-based Linux (RHEL, CentOS Stream, Fedora, Amazon Linux)
If you're using an RPM-based Linux distribution like Red Hat Enterprise Linux (RHEL), CentOS Stream, Fedora, or Amazon Linux 2023, installing RabbitMQ is best done using the official package repositories maintained by the RabbitMQ team.
This method ensures you get the latest stable versions of both Erlang (which RabbitMQ is built on) and the RabbitMQ server itself.
Step 1: Install Dependencies
RabbitMQ requires a few essential packages to manage repositories and fetch software.
# For RHEL/CentOS Stream/Fedora/Amazon Linux
sudo yum install -y curl gnupg
Step 2: Install Erlang/OTP
RabbitMQ is written in Erlang. You must install a compatible, modern version of Erlang/OTP before installing the RabbitMQ server package. The official RabbitMQ team provides a dedicated repository for this.
First, import the GPG key used to verify the authenticity of the Erlang packages:
# Import the Erlang signing key
sudo rpm --import 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xf77f1eda57ebb1cc'
Next, add the repository configuration file to your system. This file tells your package manager (YUM/DNF) where to find the correct Erlang packages:
# Add the Erlang repository file
sudo tee /etc/yum.repos.d/rabbitmq-erlang.repo <<EOF
[rabbitmq-erlang]
name=rabbitmq-erlang
baseurl=https://packagecloud.io/rabbitmq/erlang/el/8/\$basearch
repo_gpgcheck=1
gpgcheck=1
enabled=1
gpgkey=https://packagecloud.io/rabbitmq/erlang/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOF
Now, you can install the required Erlang package:
# Install Erlang/OTP
sudo yum install -y erlang
Step 3: Install RabbitMQ Server
With Erlang successfully installed, you can now add and install the RabbitMQ server.
Import the GPG key used to verify the RabbitMQ server packages:
# Import the RabbitMQ signing key
sudo rpm --import 'https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey'
Add the RabbitMQ server repository configuration file:
# Add the RabbitMQ repository file
sudo tee /etc/yum.repos.d/rabbitmq-server.repo <<EOF
[rabbitmq-server]
name=rabbitmq-server
baseurl=https://packagecloud.io/rabbitmq/rabbitmq-server/el/8/\$basearch
repo_gpgcheck=1
gpgcheck=1
enabled=1
gpgkey=https://packagecloud.io/rabbitmq/rabbitmq-server/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOF
Finally, install the RabbitMQ server package.
# Install RabbitMQ Server
sudo yum install -y rabbitmq-server
Step 4: Manage the Service
After installation, you need to start the RabbitMQ service and ensure it starts automatically after a reboot.
Use systemctl to start the service and enable it:
# Start the RabbitMQ service
sudo systemctl start rabbitmq-server
# Enable RabbitMQ to start automatically on boot
sudo systemctl enable rabbitmq-server
You can check the service status to confirm it's running:
# Check the status of the service
sudo systemctl status rabbitmq-server
Just like on Ubuntu, the useful Web Management Plugin is not enabled by default. To get the graphical dashboard (which runs on port 15672), enable the plugin and restart the service:
# Enable the web management plugin
sudo rabbitmq-plugins enable rabbitmq_management
# Restart the service to apply the plugin changes
sudo systemctl restart rabbitmq-server
You can now access the dashboard at http://localhost:15672 using the default credentials: guest/guest.
How to install RabbitMQ admin dashboard in Linux?
By default, RabbitMQ is managed only via the command line. To get the friendly web interface (the Management Plugin), you need to enable it using a simple command:
sudo rabbitmq-plugins enable rabbitmq_management
Once the plugin is enabled, you can access the dashboard in your web browser.
- URL: Go to http://localhost:15672
-
Default Login: Use the default, out-of-the-box credentials:
-
Username:
guest -
Password:
guest
-
Username:
The administration screen allows you to easily monitor the volume of messages (Ready vs. Unacknowledged), check active Connections and Queues, and view server resources like Memory and Disk space.
Configuring RabbitMQ users
To add a user in RabbitMQ you can use web management or command line with the below command:
$ sudo rabbitmqctl add_user your_user your_password
Adding user "your_user" ...
$ sudo rabbitmqctl set_user_tags your_user administrator
Setting tags for user "your_user" to [administrator] ...
Or using web management tool:
To change the password for an existing user, you can use the below command:
sudo rabbitmqctl change_password guest guest123@#
Installing RabbitMQ on Windows (Using the Installer)
The easiest and most common way to install RabbitMQ on a Windows system is by using the official Windows Installer (.exe). Remember that Erlang must be installed first, as RabbitMQ is built using the Erlang language.
Step 1: Install Erlang/OTP (The Prerequisite)
RabbitMQ relies entirely on the Erlang platform to run. You must install Erlang before installing RabbitMQ.
- Download Erlang: Go to the official Erlang website and download the latest 64-bit installer for Windows.
-
Run the Installer: Execute the downloaded file. Follow the installation prompts, usually accepting the default options.
- Tip: It is highly recommended to run the installer using an administrative account.
Step 2: Install RabbitMQ Server
Once Erlang is successfully installed, you can install the RabbitMQ server.
- Download RabbitMQ: Visit the official RabbitMQ Downloads page and get the latest RabbitMQ Server Windows installer (.exe file).
- Run the Installer: Double-click the downloaded file. The installer will install RabbitMQ as a Windows Service and start it automatically using the default configuration.
Step 3: Enable the Web Management Dashboard
By default, RabbitMQ is managed via the command line. To get the graphical web interface, you need to enable the management plugin.
-
Open Command Prompt (Admin): Search for
cmd, right-click, and select "Run as administrator". -
Run the Plugin Command: Execute the following command to activate the plugin.
rabbitmq-plugins enable rabbitmq_management -
Restart the Service: The service needs to be restarted for the plugin to take effect.
# Stop the service rabbitmq-service stop # Start the service rabbitmq-service start
Step 4: Access the Dashboard
You can now access the management interface through your web browser.
- URL: Go to http://localhost:15672
-
Default Login: The default username is
guestand the password isguest.
This dashboard lets you monitor connections, queues, message rates, and server health.
If you're interested in alternative methods, you can also install RabbitMQ on Windows using the Chocolatey package manager.
This video shows a step-by-step guide on How to install #RabbitMQ on windows 10 step by step.
That's all, folks!





Top comments (0)