RabbitMQ is a message queue system. It lets computer programs send each other work to do, without waiting for them to do it.
I’ve been getting this working on the open-source FreeBSD unix-like system. These are notes on getting started. This writeup was helpful to me.
Install it and get it working
As with any complex server software, there are a few steps to getting it working. These steps worked for me.
To install a working RabbitMQ server on FreeBSD, use this commands You need to do all this stuff as root.
pkg install rabbitmq
Then, edit /etc/rc.conf to include the line
rabbitmq_enable=”YES”
Next, start the RabbitMQ server you just installed.
/usr/local/etc/rc.d/rabbitmq start
Check that the server is running. You should get an information report from this command.
rabbitmqctl status
Enable the web-based management plugin.
rabbitmq-plugins enable rabbitmq_management
Create an administrative user for your server.
rabbitmqctl add_user administrator choose_a_password
rabbitmqctl set_permissions -p / administrator “.*” “.*” “.*”
rabbitmqctl set_user_tags administrator administrator
Use a web browser to look at your server at http://your-server-ip:15672/ . Port 15672 is the RabbitMQ web administration portal.
If you get the administration web page, you’ve successfully set things up. Finally, reboot your server to make sure everything comes back up correctly.
Finally, install the RabbitMQAdmin program where your user can get to it on your FreeBSD machine. This program is a script provided by the web administration portal. (It needs python 2.7 to run.)
wget http://127.0.0.1:15672/cli/rabbitmqadmin
chmod 0755 rabbitmqadmin
You may have to edit this script to put the name of your installed python2 interpreter at the top.
Sources of information
rabbitmqctl is the control program. It’s actually a shell script that must be able to run as the rabbitmq user. So, it’s a good idea to install the sudo package.
rabbitmqadmin is the administrator’s program. It’s useful for showing content.
Sending and Receiving Messages
Once the server is running, let’s try it out. First, we need to create a queue.
python2 rabbitmqadmin declare queue name=test durable=false
Then we can send and receive messages.
python2 rabbitmqadmin publish routing_key=test payload=”Sending out an SOS.”
python2 rabbitmqadmin publish routing_key=test payload=”Message in a bottle.”
python2 rabbitmqadmin get queue=test requeue=false
python2 rabbitmqadmin get queue=test requeue=false
Of course, the point of all this is to do it with programs, not command lines.