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:
NODENAME=bunny@sally
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:
rabbitmq_enable="YES"
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 Password: Status of node bunny@sally ... [{pid,20553}, {running_applications,[{rabbit,"RabbitMQ","3.3.0"}, {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"}]}, {os,{unix,freebsd}}, {erlang_version,"Erlang R16B03-1 (erts-5.10.4) [64-bit] [smp:2:2] [async-threads:30] [kernel-poll:true]\n"}, {memory,[{total,36576256}, {connection_procs,2704}, {queue_procs,5408}, {plugins,0}, {other_proc,13405832}, {mnesia,60112}, {mgmt_db,0}, {msg_index,31000}, {other_ets,819464}, {binary,177000}, {code,16707119}, {atom,602729}, {other_system,4764888}]}, {alarms,[]}, {listeners,[{clustering,25672,"::"},{amqp,5672,"0.0.0.0"}]}, {vm_memory_high_watermark,0.4}, {vm_memory_limit,6636242534}, {disk_free_limit,50000000}, {disk_free,2822591588352}, {file_descriptors,[{total_limit,10995}, {total_used,3}, {sockets_limit,9893}, {sockets_used,1}]}, {processes,[{limit,1048576},{used,126}]}, {run_queue,0}, {uptime,785}] ...done.
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(level=logging.ERROR) #logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.CRITICAL) # #logging.getLogger('pika').setLevel(logging.DEBUG) connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost')) channel = connection.channel() channel.queue_declare(queue='hello') channel.basic_publish(exchange = '', routing_key = 'hello', body = 'Hello World!') print " [x] Sent 'Hello World!'" connection.close()
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> (192.168.11.53:54560 -> 192.168.11.53:5672) =INFO REPORT==== 10-Apr-2014::23:04:12 === closing AMQP connection <0.260.0> (192.168.11.53:54560 -> 192.168.11.53:5672)
Sure enough, that’s just the input to the queue, but that’s enough to get you started.