RabbitMQ is an open-source “message broker” that facilitates communication between distributed applications with the Advanced Message Queuing Protocol (AMQP) [Link].

In RabbitMQ, producers send messages to a “queue,” from which consumers asynchronously read and process those messages.

It also offers various features like load balancing, message routing, and data persistence.

RabbitMQ is often compared to Apache Kafka [Link], which is an open-source “distributed event streaming platform”. In other words, they have their similarities but they are not direct competitors.

Main differences:

  • RabbitMQ much easier to deploy and manage. Kafka has a very steep learning curve.
  • RabbitMQ pushes messages to consumers, while Kafka’s consumers pull messages and keep track of what has been consumed by using offsets.
  • RabbitMQ uses AMQP, and Kafka uses a custom protocol over TCP.
  • RabbitMQ is more focused on message queues, whereas Kafka is designed around the concept of an immutable log of events.
  • Both support “at least once” and “at most once” delivery, but Kafka also offers “exactly once” semantics.

DEPLOYMENT AS CONTAINER

sudo apt update && sudo apt upgrade -y
sudo apt install docker.io -y
sudo docker run -it --rm --name RabbitMQ -p 5672:5672 -p 15672:15672 rabbitmq:3.12-management

INSTALLATION FROM DEB PACKAGES

Note that is requires Erlang to be installed before because RabbitMB is written on it.

sudo apt update && sudo apt upgrade -y
sudo apt-get install curl gnupg apt-transport-https -y

Add the signing keys and repositories.

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://ppa.novemberain.com/gpg.E495BB49CC4BBE5B.key | sudo gpg --dearmor | sudo tee /usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg > /dev/null
curl -1sLf https://ppa.novemberain.com/gpg.9F4587F226208342.key | sudo gpg --dearmor | sudo tee /usr/share/keyrings/rabbitmq.9F4587F226208342.gpg > /dev/null
sudo nano /etc/apt/sources.list.d/rabbitmq.list

Add the following content to the file:

deb [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu $distribution main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu $distribution main
deb [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu $distribution main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu $distribution main
deb [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu $distribution main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu $distribution main
deb [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu $distribution main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu $distribution main

Then, proceed with the instalation of the RabbitMQ it self.

sudo apt-get update -y
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
sudo apt-get install rabbitmq-server -y --fix-missing

MANAGING RABBITMQ

sudo systemctl enable rabbitmq-server
sudo systemctl start rabbitmq-server
sudo systemctl status rabbitmq-server
sudo journalctl --system | grep rabbitmq
sudo rabbitmq-diagnostics status
sudo rabbitmq-diagnostics ping
sudo rabbitmq-diagnostics cluster_status
sudo rabbitmq-diagnostics environment
sudo rabbitmq-plugins list

Enable the plugins:

sudo rabbitmq-plugins enable rabbitmq_management

Remember to open port 5672 on the firewall with appropriate roles for the queue API, and 15672 for the Management Web Console.