Message brokers help apps work independently and handle tasks in the background. They’re a key part of event-driven systems. RabbitMQ is one of the most widely used message brokers.
In this blog, we’ll show you how to:
- Set up RabbitMQ on your local machine using Docker
I assume that you have Docker Desktop available on your computer. If not, please install it from here.
Option 1. Run RabbitMQ in a Docker Container
We'll use the official RabbitMQ Docker image that includes the management plugin, so we get a web-based interface (GUI) to work with.
Docker Command to install the rabbitmq
docker run --hostname my-rabbit --name rabbitmq-dev -p 5672:5672 -p 15672:15672 -d rabbitmq:3-management
- Port 5672: Used by RabbitMQ clients, such as your Web API
- Port 15672: Used to access the RabbitMQ management interface through a web browser
- Access Management UI: browse the url http://localhost:15672 and use the credentials: Username:guest and Password:guest.
![RabbitMQ]()
Option 2. Install RabbitMQ Locally (Without Docker)
If you prefer to run RabbitMQ natively:
Step 1. Install Erlang
RabbitMQ depends on Erlang. Download it from:
https://www.erlang.org/downloads
Step 2. Install RabbitMQ
Download the RabbitMQ installer for our OS.
https://www.rabbitmq.com/docs/download
Follow the installation wizard and start the RabbitMQ Service.
Step 3. Enable the management Plugin
Run the following command in the terminal (as admin):
rabbitmq-plugins.bat enable rabbitmq_management
Notes
- Ensure that the rabbitmq-plugins.bat file is included in your system's PATH environment variable.
- You may need to run the Command Prompt with Administrator privileges.
- If the command doesn't work, try navigating to the RabbitMQ sbin directory manually before executing it.
cd "C:\Program Files\RabbitMQ Server\rabbitmq_server-3.x.x\sbin"
rabbitmq-plugins.bat enable rabbitmq_management
(Replace 3.x.x with your actual RabbitMQ version.)
After enabling the plugin, restart RabbitMQ with:
rabbitmq-service.bat stop
rabbitmq-service.bat start
or Simply
net stop RabbitMQ
net start RabbitMQ
Conclusion
Running RabbitMQ locally is simple and quick with Docker. It provides a real messaging environment that you can use to develop and test features like:
- Event-driven architecture
- Message retries
- Dead-letter queues
- Microservice communication
By using the management UI, you can easily monitor queues, exchanges, and messages.