Installing and Configuring RabbitMQ

rabbitmq logo

RabbitMQ and AMQP (Advanced Message Queuing Protocol) are gaining momentum in the market. One of the main reasons for that momentum is because, in enterprise development, the client is not always Java specific. With RabbitMQ, we can configure a scalable, fault-tolerant, open-source messaging solution for polyglot clients, click here to see a list of client language support.

Follow the steps below to install and configure RabbitMQ v1.7.x on a MAC with OSX Lion. Click here for installation instructions for Windows and other platforms.


1. Installing RabbitMQ

Mac OSX Lion Installation

Install HomeBrew

From the terminal prompt:

$ brew install rabbitmq

We do NOT need to install Erlang, however, if desired use Brew as follows:

$ brew install erlang

HomeBrew RabbitMQ Directories

  • Logs: /usr/local/var/log/rabbitmq
  • Config: /usr/local/etc/rabbitmq
  • Mnesia Database: /usr/local/var/lib/rabbitmq/mnesia
  • Erlang cookie: <homedir>/.erlang.cookie

Mnesia is a NoSql database that stores RabbitMQ configuration data – Mnesia Reference Manual.


2. Configuring RabbitMQ Server

When RabbitMQ is installed, not all of the configuration files exist.

Do not be concerned if the install does not contain the files mentioned, simply create the text files and use the contents provided below as a base.

In the rabbitmq-env.conf file, any variables referenced can be set using an environment variable with the prefix RABBITMQ_, for example NODE_PORT=5672 can be set as an environment variable export RABBITMQ_NODE_PORT=5672

N.B. the system name in the examples is “Technophiliac”. In configuring your system, simply change all references from “Technophiliac” to your system name.

RabbitMQ Environment Configuration File

Create or edit /usr/local/etc/rabbitmq/rabbitmq-env.conf

# ##############################
# RABBITMQ SERVER CONFIGURATION
#
# All of the parameters below can also
#   be set as environment variables
#   using the prefix "RABBIT_"
#   i.e.  export RABBITMQ_NODE_PORT=5672
## ##############################

# ##########################
# Defaults to the empty string
#   meaning bind to all network interfaces
# Change to bind to one network interface only
# ##########################
# NODE_IP_ADDRESS=
# NODE_PORT=5672

# ##########################
# Unix, Linux: `env hostname`
# MacOSX: `env hostname -s`
# The name of the current machine
# ##########################
# HOSTNAME=

# ##########################
# The name of the current machine
# ##########################
# COMPUTERNAME=

# ##########################
# This base directory contains sub-directories for
#   server's db and log files
# Alternatively, set MNESIA_BASE and LOG_BASE individually
# ##########################
# BASE=

# ##########################
# Mac/Unix: rabbit@$HOSTNAME
# The node name should be unique per erlang-node-and-machine combination
# To run multiple nodes, see the clustering guide
# ##########################
# NODENAME=

# ##########################
# Mac: /usr/local/etc/rabbitmq/rabbitmq
# If the configuration file is present it is used by the server
# The .config extension is automatically appended
# This file is also used to auto-configure RabbitMQ clusters
# Example:
#   Config file location and new filename bunnies.config
#   CONFIG_FILE=/usr/local/etc/rabbitmq/bunnies
# ##########################
CONFIG_FILE=/usr/local/etc/rabbitmq/rabbitmq

# ##########################
# Mac: /usr/local/var/lib/rabbitmq/mnesia
# The Mnesia database files directory
#
# MNESIA_DIR will be assembled as MNESIA_BASE/NODENAME
# ##########################
# MNESIA_BASE=
# MNESIA_DIR=

# ##########################
# Mac: /usr/local/var/log/rabbitmq
# Log files generated by the server will be placed in this directory.
# ##########################
# LOG_BASE=/usr/local/var/log/rabbitmq

# ##########################
# The plugins directory
# ##########################
PLUGINS_DIR=/usr/local/Cellar/rabbitmq/2.7.1/lib/rabbitmq/erlang/lib/rabbitmq-2.7.1/plugins

# ##########################
# Mac: /usr/local/etc/rabbitmq/enabled_plugins
# This file declares explicitly enabled plugins
# ##########################
ENABLED_PLUGINS_FILE=/usr/local/etc/rabbitmq/enabled_plugins

RabbitMQ Server Configuration File

Create or edit the file /usr/local/etc/rabbitmq/rabbitmq.config

[{auth_backends,[rabbit_auth_backend_internal]},
 {auth_mechanisms,['PLAIN','AMQPLAIN']},
 {backing_queue_module,rabbit_variable_queue},
 {cluster_nodes,[]},
 {collect_statistics,fine},
 {collect_statistics_interval,5000},
 {default_permissions,[<<".*">>,<<".*">>,<<".*">>]},
 {default_user,<<"guest">>},
 {default_user_tags,[administrator]},
 {default_vhost,<<"/">>},
 {delegate_count,16},
 {error_logger,{file,"/usr/local/var/log/rabbitmq/rabbit@Technophiliac.log"}},
 {frame_max,131072},
 {hipe_compile,false},
 {included_applications,[]},
 {msg_store_file_size_limit,16777216},
 {msg_store_index_module,rabbit_msg_store_ets_index},
 {queue_index_max_journal_entries,262144},
 {sasl_error_logger,{file,"/usr/local/var/log/rabbitmq/rabbit@Technophiliac-sasl.log"}},
 {server_properties,[]},
 {ssl_listeners,[]},
 {ssl_options,[]},
 {tcp_listen_options,
   [binary,
     {packet,raw},
     {reuseaddr,true},
     {backlog,128},
     {nodelay,true},
     {exit_on_close,false}]},
 {tcp_listeners,[5672]},
 {trace_vhosts,[<<"/">>]},
 {vm_memory_high_watermark,0.4}]


3. Configuring RabbitMQ Console Plugins

RabbitMQ Console Plugins File

Create or edit the text file /usr/local/etc/rabbitmq/enabled_plugins

Include the following content (don’t forget the period at the end)

[rabbitmq_jsonrpc_channel,
 rabbitmq_jsonrpc_channel_examples,
 rabbitmq_management,
 rabbitmq_management_visualiser,
 rabbitmq_tracing].


4. Set Environment Variables

export RABBITMQ_HOME=/usr/local/Cellar/rabbitmq/2.7.1
export HOMEBREW_LIBRARY_PATH=$HOMEBREW_LIBRARY_PATH:$LD_LIBRARY_PATH
export CPLUS_INCLUDE_PATH=/usr/local/include:$CPLUS_INCLUDE_PATH
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:/usr/local/lib/python:$PYTHONPATH
export LDFLAGS=-L/usr/local/Cellar/readline/6.2.2/lib
export CPPFLAGS=-I/usr/local/Cellar/readline/6.2.2/include


5. Starting RabbitMQ

$ sudo rabbitmq-server

We will see the following console output:

Activating RabbitMQ plugins ...
12 plugins activated:
* amqp_client-0.0.0
* mochiweb-1.3-rmq0.0.0-git
* rabbitmq_jsonrpc-0.0.0
* rabbitmq_jsonrpc_channel-0.0.0
* rabbitmq_jsonrpc_channel_examples-0.0.0
* rabbitmq_management-0.0.0
* rabbitmq_management_agent-0.0.0
* rabbitmq_management_visualiser-0.0.0
* rabbitmq_mochiweb-0.0.0
* rabbitmq_tracing-0.0.0
* rfc4627_jsonrpc-0.0.0-git
* webmachine-1.7.0-rmq0.0.0-hg

+---+   +---+
|   |   |   |
|   |   |   |
|   |   |   |
|   +---+   +-------+
|                   |
| RabbitMQ  +---+   |
|           |   |   |
|   v2.7.1  +---+   |
|                   |
+-------------------+
AMQP 0-9-1 / 0-9 / 0-8
Copyright (C) 2007-2011 VMware, Inc.
Licensed under the MPL.  See http://www.rabbitmq.com/

node           : rabbit@Technophiliac
app descriptor : /usr/local/Cellar/rabbitmq/2.7.1/lib/rabbitmq/erlang/lib/rabbitmq-2.7.1/ebin/rabbit.app
home dir       : /Users/gordondickens
config file(s) : /usr/local/etc/rabbitmq/rabbitmq.config
cookie hash    : VBuPLzEtAR8Sdq9eR1g36w==
log            : /usr/local/var/log/rabbitmq/rabbit@Technophiliac.log
sasl log       : /usr/local/var/log/rabbitmq/rabbit@Technophiliac-sasl.log
database dir   : /usr/local/var/lib/rabbitmq/mnesia/rabbit@Technophiliac
erlang version : 5.8.5

-- rabbit boot start
starting file handle cache server                                     ...done
starting worker pool                                                  ...done
starting database                                                     ...done
starting codec correctness check                                      ...done
-- external infrastructure ready
starting plugin registry                                              ...done
starting auth mechanism cr-demo                                       ...done
starting auth mechanism amqplain                                      ...done
starting auth mechanism plain                                         ...done
starting statistics event manager                                     ...done
starting logging server                                               ...done
starting exchange type direct                                         ...done
starting exchange type fanout                                         ...done
starting exchange type headers                                        ...done
starting exchange type topic                                          ...done
-- kernel ready
starting alarm handler                                                ...done
starting node monitor                                                 ...done
starting cluster delegate                                             ...done
starting guid generator                                               ...done
starting memory monitor                                               ...done
-- core initialized
starting empty DB check                                               ...done
starting management agent                                             ...done
starting exchange, queue and binding recovery                         ...done
starting mirror queue slave sup                                       ...done
starting adding mirrors to queues                                     ...done
-- message delivery logic ready
starting error log relay                                              ...done
starting networking                                                   ...done
starting direct_client                                                ...done
starting notify cluster nodes                                         ...done

broker running
** Found 0 name clashes in code paths 


The Console

After RabbitMQ starts, go to the console http://localhost:55672/
NOTE: The default user id/password is guest/guest.


Summary

In this blog we saw the steps to install and configure RabbitMQ to run locally on Mac OSX Lion. In the next blog, I’ll introduce the concepts of AMQP exchanges, routes and queues, using Groovy Scripts to create and test them. We will also discover how to visualize those components and their relationships within the console.

About Gordon

Technology enthusiast primarily focused on Java and Open Source projects. Spring Certified Professional and Trainer. http://twitter.com/gdickens http://linkedin.com/in/gordondickens http://github.com/gordonad
This entry was posted in AMQP, Erlang, HomeBrew, RabbitMQ and tagged , , , . Bookmark the permalink.

One Response to Installing and Configuring RabbitMQ

  1. Pingback: Ceolya | Pearltrees

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>