What is it?
Rabbit MQ is a queuing service built on the AMQP.
Roles
There are two roles:
- Producer - A Producer will produce a message and pass it to an exchange. The exchange will use some rules to decide which queue the message goes in.
- Consumer - A Consumer consume messages from specific queues. In other words, they take the things the producers put in the queue, and they do something with it.
The rate of consumption, on average, must be higher than the rate of message production. Otherwise your queue will inevitably grow, and as of today, infinitely sized disks don’t exist. The major benefit here is that you can scale up either side independently in order to keep this balance.
Exchange types
How the exchange routes the message is also somewhat configurable. There are four exchange types available.
- fanout - Fanout will send the received message to all queues it knows about. eg: Broadcast.
- direct - Message goes to the queue whose binding key matches our messages routing key.
- headers - Allows you to route messages based on custom headers.
- topic - This is basically direct, with two special cases for “*”, and “#”.
CentOS7: Install and Configure
dnf -y install https://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
dnf -y install erlang
dnf -y install https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.15/rabbitmq-server-3.6.15-1.el7.noarch.rpm
We now have RabbitMQ installed, now we need to configure it.
systemctl start rabbitmq
Systemctl enable rabbitmq
rabbitmqctl add_user $your_user $your_password
rabbitmqctl set_user_tags $your_user administrator
rabbitmqctl set_permissions -p / $your_user ".*" ".*" ".*"
Obviously replace my variables with your username and password. What we did was, add a user, tag that user as administrator, and then set the permissions. The syntax is set_permissions [-p <vhost>] <user> <conf> <write> <read>
in case you were curious.
Plugins
rabbitmq-plugins enable rabbitmq_shovel rabbitmq_shovel_management
If you want to install the pretty little UI, do the above. You will now notice you have a UI running on port 15672. If you navigate there, you can login with the user/password you created.