Apr 102014

I’m starting to play with RabbitMQ as part of a new project. The first goal: get it installed and running.

I’m going to do this in a jail running FreeBSD 9.2, but this should be the same if you running a non-jail. I installed via: pkg install rabbitmq

In /usr/local/etc/rabbitmq/rabbitmq-env.conf I have the following:


NOTE: change sally to the hostname you are installing on.

I an doing this in a jail. In my jail. lo0 does not have an IP address, which is why /usr/local/etc/rabbitmq/rabbitmq-env.conf contains this:

$ cat rabbitmq.config
[{rabbit, [{loopback_users, []}]}].

I found that answer in the documentation.

I added this to /etc/rc.conf:


To start rabbitmq:

# service rabbitmq start
Warning: PID file not written; -detached was passed.

When I issue a status command, I see this:

# service rabbitmq status
Status of node bunny@sally ...
                        {mnesia,"MNESIA  CXC 138 12","4.11"},
                        {os_mon,"CPO  CXC 138 46","2.2.14"},
                        {xmerl,"XML parser","1.3.6"},
                        {sasl,"SASL  CXC 138 11","2.3.4"},
                        {stdlib,"ERTS  CXC 138 10","1.19.4"},
                        {kernel,"ERTS  CXC 138 10","2.16.4"}]},
 {erlang_version,"Erlang R16B03-1 (erts-5.10.4)  [64-bit] [smp:2:2] [async-threads:30] [kernel-poll:true]\n"},

I installed the Python client, devel/py-pika.

I create this test program, based on the official Python tutorial and some Twitter advice:

$ cat ./send.py
#!/usr/bin/env python
import pika
import logging

#logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.CRITICAL)

connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()

channel.basic_publish(exchange    = '',
                      routing_key = 'hello',
                      body        = 'Hello World!')
print " [x] Sent 'Hello World!'"


Running that program give does this:

$ ./send.py
 [x] Sent 'Hello World!'

When the above command was issues, this appeared in the logs at /var/log/rabbitmq/bunny@sally.log (or whatever you specified for NODENAME in /usr/local/etc/rabbitmq-env.conf):

=INFO REPORT==== 10-Apr-2014::23:04:12 ===
accepting AMQP connection <0.260.0> ( ->

=INFO REPORT==== 10-Apr-2014::23:04:12 ===
closing AMQP connection <0.260.0> ( ->

Sure enough, that’s just the input to the queue, but that’s enough to get you started.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive