How to work with RabbitMQ Server on Ubuntu .

Reading Time: 4 minutes

What is RabbitMQ ?

RabbitMQ is an opensource message broker.It is used widely and is lightweight , easy to deploy in environments.

In simple words it acts as a middleman for various services. Lets consider an example that there is a application which inputs user data from users. Now to do such task for thousand request the application will take time. So RabbitMQ acts as a broker for the publisher and consumer. The data is in queue till the consumer subscribes it.

RabbitMQ Working

How to install RabbitMQ on Ubuntu ?

To install RabbitMQ you should have Erlang installed on your system. Erlang is a general purpose functional programming language and runtime environmnent. It is used to build scalable and concurrentr system .

Install Erlang on your local.

1 – Import GPG Key

To do this run the below command :-

sudo apt update
sudo apt install software-properties-common apt-transport-https

wget -O- | sudo apt-key add -

2 – Next add the Erlang Repo to Ubuntu

To add the repo run the below command on your terminal

echo "deb focal contrib" | sudo tee /etc/apt/sources.list.d/erlang.list

3 – Now install using the below command.

Now the work is to update and install erlang by the below comamd.

sudo apt update
sudo apt install erlang

So the output of the above is as follows:-

rishivant@rishivant-Vostro-3590:~$ sudo apt install erlang
[sudo] password for rishivant: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
erlang is already the newest version (1:24.2.1-1).
The following packages were automatically installed and are no longer required:
  chromium-codecs-ffmpeg-extra gstreamer1.0-vaapi hplip-data libgstreamer-plugins-bad1.0-0 libimagequant0 libllvm11 mongodb-database-tools
  printer-driver-postscript-hp python3-olefile python3-pil python3-renderpm python3-reportlab python3-reportlab-accel
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 59 not upgraded.

rishivant@rishivant-Vostro-3590:~$ erl
Erlang/OTP 24 [erts-12.2.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Eshell V12.2.1  (abort with ^G)

As the above output shows that the erlang is now installed so next we have to install RabbitMQ repository to Ubuntu.

Next Install RabbitMQ server in your system

Lets start by importing the GPG key. To do this follow the below code for Ubunutu 20.4 and 18.04

echo "deb focal main" | sudo tee /etc/apt/sources.list.d/rabbitmq-server.list

The above code will let you import and add the repo . Then the next step is to configure the RabbitMQ repositories using the below command

curl -s | sudo bash

The output of the above command will be as follows :-

1 -Install RabbitMQ after setting up the repository

To install RabbitMQ after this run the below two commands.

sudo apt update

sudo apt install rabbitmq-server

The above will update and install RabbitMQ on your system. After the server is set up check for the status of the server by following the below output.

The above image is the running services image.

Working of RabbitMQ Using the dashboard.

To make thing easier and let the broker work properly we need to enable the dashboard at port number 15672.

To achieve the above we need to runa simple command i.e

sudo systemctl enable rabbitmq-server

The above command will open a managemnet dashboard that makes things easier and help us achieve the fact more easily.Basically this works by using plugins thta it enables on running the above command.

Next head over to your browser and type localhost:15672

How the Dashboard looks ?

So once you will head over to the above port , the dashboard will open and the output will be as below .

RabbitMQ dashboard

The above dashboard shows the username and password which will be normally used as guest and guest. Click on the login once done with the username and pass.

2 – Services in RabbitMQ server.

The services page is the page where all the nav are there. The dashboard helps you deal with Connections , Channels , Exchanges , Queues , Admin .

The front page shows the messages queued , rates at which the messages are published.

Front page RabbitMq

This is the page where all the services are displayed of the message broker. Once done the publish subscribe rate can been seen from here.

3 – Queues in RabbitMQ server.

RabbitMQ - Queue

Now the queue shows the state of the job of services that will be publishing messages through this broker.

Here all the state and incoming can be found.The queue represents all the jobs that publishes to the broker.The queue displays the messages in wait . So to find it more easily the UI is there to help it .

For more help visit this blog –



Written by 

Rishivant is a enthusiastic devops learner at Knoldus. He believes in going 1% up everyday and showcases his learning in his work.