December 15, 2013

Starting Rabbit MQ up for your Mac

Been working with Message Queues more and more. They seem like the building blocks required for SOA development. One queue I have been working with, on my own has been Rabbit MQ. There were a couple of things I noticed that I had to do when installing it from Homebrew. Thought I would write a series of articles on setting up Rabbit MQ, starting with setup.

I develop on a Mac, from time to time, to see how it is compared to Windows. While there are a few things different, it’s mostly the same. One of the best things about Unix/Linux are their package managers, like Homebrew (Unix) and apt-get (Linux)

To start installing Rabbit MQ on Mac, you have to fire up a couple of commands:

 brew update brew install rabbitmq 

The first command updates the brew repository listing to get the most up-to-date applications. This may be needed for installing the dependencies, like Erlang. The second line actually installs rabbitmq. This is a side note, I had some issues with installing, but I think it was with brew. It wanted to install some man files(RTFM files), but couldn’t. I just ended up giving the man directory some more access, so if that happens, just be aware.

When Rabbit MQ is installed, there are a couple of scripts created to help the whole process of administrating the site. They should be located:

 ls /usr/local/sbin/rabbit* 

Each one is an important script that automates starting up Rabbit MQ and various other things. If you can, I would add this directory, and /usr/local/bin, to your .bash\_profile . Once done, run the script:

 rabbitmq-server 

This will start the server completely, including the administration console. Now to run commands on the admin console, there are 2 ways. The one way is through the command line, using the scripts in /usr/local/sbin. The command is rabbitmqctl. The other way is to visit localhost:15672, in your browser. The default user/password is guest/guest. Once you have changed some names and passwords, there is ONE more thing to get all of this to work right, namely the IP address binding.

By default, Rabbit MQ is bound ONLY to localhost. We should change it, especially if you are working out of a VM or on multiple machines. Otherwise, only requests from localhost can use RabbitMQ. To do this you have to visit:

 pico /usr/local/etc/rabbitmq/rabbitmq-env.conf 

You should see NODE\_IP_ADDRESS=LOCALHOST, change this to blank, if you want it to listen on all network interfaces. Or, you could change it to a specific IP address if you only want requests coming from that network. You also may have to run this as sudo.

Lastly, to test to see if it works, there are a bunch of examples on Rabbit MQ tutorial site. Grab one down and go. Next time, I will explain the various queue types and how they work.