Getting Started

Emrah Ayanoglu

December 2015

In this article written by Emrah Ayanoglu, authors of the book Mastering RabbitMQ, states that "scalability is one of the major problems of our time, and messaging is an integral part of the solution". It finally comes down to the message broker software to manage and control messaging between applications, processes and threads. Message brokers can help to solve scalability issues and architectural issues like coupling.

(For more resources related to this topic, see here.)

RabbitMQ is one of the most powerful open source message broker software that is widely used in the tech companies such as Mozilla, VMware, Google, AT&T and so on. RabbitMQ is a highly configurable messaging platform developed and supported by a knowledgeable and committed community.

Before diving into the details and technologies behind the RabbitMQ, let us introduce you to the following topics in this article:

  • A brief introduction to message brokers and message queue
  • Introduction to advanced message queue protocol
  • Getting started with RabbitMQ
  • Installation of RabbitMQ
  • Starting RabbitMQ
  • Summary

Message brokers and message queue

Recently, software systems evolved dramatically. Applications has to communicate with other applications where these applications can be internal and external to application itself. For the same application we may have different type of clients such as browsers, mobile clients and so forth. Hence, we absolutely need a communication layer between inter-applications and applications-clients. We need to deliver different messages to different applications or clients. Delivering messages can be a bottleneck if communication layer isn't scalable. Pursuing scalable systems for communication layer lead us to Message Brokers and Message Queues. Let's introduce ourselves to what Message Brokers and Message Queues are.

Message brokers

Message Broker is an architectural pattern that can receive messages from multiple destinations, determine the correct destination, and route the message along the correct route, according to Hohpe's and Woolf's Enterprise Integration Patterns book (Enterprise Integration Patterns, Hohpe, Woolf). Message brokers enable systems to deal with messaging and routing by mediating communication among components. Once applications implement message broker pattern, it decreases coupling between application components.

Message Brokers are centralized, in the architectural sense, to control and manage all messages. Therefore, all of the incoming and outgoing messages are sent through Message Brokers, which analyzes the message and delivers message to their correct destination. This procedural step could be understood with the following image:

Message Broker

Message Brokers addresses following concerns in the communication layer:

  • Transform messages to alternative formats
  • Route messages to destinations
  • Supports different type of patterns to send messages
  • Receives and responds to events
  • Perform message aggregation
  • Persists the message states
  • Ensures the message receiving and sending
  • Decouples the destination software systems

Many tasks of the Message Broker need a Message Queue for exchanging or passing data to destination. Next part covers the brief information about the Message Queues.

Message queue

Message Queue is, briefly, a queue for messaging. Queue is the basic data structure behind the functioning of a Message Queue. Message Queue operations are similar to that of a Queue data structure operations such as, an enqueue or dequeu. An enqueue operation leads to add element to the back of the queue. a dequeue operation leads to deletion of an element from the front of the queue.

Message Queues provide concurrent and asynchronous operations to scale applications. In a message queue, messages wait up until message is retrieved by an application.

Message Queue

Different type of standards and protocols define the Message Queuing specifications. Some protocols are open to everyone; however, some protocols are closed. Let's come back to our topic. RabbitMQ uses Advanced Message Queuing Protocol (AMQP) that determines the policies of the Message Queues. Next topic could cover the brief information to AMQP.

Introduction to advanced message queue protocol

John O'Hara from JP Morgan's started AMQP in 2003. He put incredible amount of work to it. Then, JP Morgan approached other firms to establish an organization for creating open standards in messaging. According to AMOPs official website, AMQP is an open standard for passing messages between applications or organizations ( So, AMQP just defines the messaging properties, queue properties, how messages are routed between applications, clients, how Message Brokers ensure that the message is received or sent, and other concerns such as reliability and security.

AMQP has lots of capabilities to accomplish goals according to AMQP website (

  • Security
  • Reliability
  • Interoperability
  • Standard
  • Open

Interoperability and reliability are very important for today's software engineering problems. The power of AMQP comes from its features like interoperability, reliability and so forth. Especially, with interoperability, we can use different type of technologies in sender and receiver. The main problem for most of the Internet giants' is scalability. Scalability has direct relationship to reliability.

An overview of RabbitMQ

As mentioned earlier, RabbitMQ is an open source Message Broker software that tries to solve messaging problems via implementing the AMQP. RabbitMQ is licensed with Mozilla Public License. RabbitMQ became part of GoPivotal in May 2013 and the community has helped in the development of RabbitMQ. Since then, the community has been trying to improve RabbitMQ.

RabbitMQ logo

As we explained that RabbitMQ solves the messaging problems; however, you may ask yourself that what kind of messaging problems RabbitMQ solves. In summary, RabbitMQ has the following functionalities to solve messaging problems:

  • Ensure message sent and received
  • Routing the messages to the correct destinations
  • Saves the state of the messages
  • Supports multiple transportation protocols (AMQP, MQTT, STOMP, HTTP)
  • Supports clustering
  • Highly scalable, reliable and available
  • Extendible with plugins
  • Supports clients for almost any of language
  • Large community support also have commercial support

Now that we have discussed concepts behind the RabbitMQ and RabbitMQ itself, let's try to install and use RabbitMQ on your computer.

Installation of RabbitMQ

Installation of RabbitMQ is not distinctly different from other software in different operation systems. Unix based operating systems can build RabbitMQ from source code and Microsoft Windows can run the standard MSI installers. RabbitMQ installation files could be found in the download webpage of RabbitMQ website as shown in the following image:

Download Webpage of RabbitMQ

The only prerequisite for the RabbitMQ installation is Erlang runtime environment because RabbitMQ runs on the Erlang VM. Therefore, we have to install Erlang before installing the RabbitMQ. Erlang could be downloaded from the Erlang download webpage as shown in the following image and installation instructions will be covered in the topics that will follow:

Download Webpage of Erlang

Now, we'd like to talk about installation of both RabbitMQ and Erlang starting from Windows, Mac OS X, Ubuntu, Fedora and Amazon Web Services.

Windows installation

RabbitMQ runs on both 32 bit and 64 bit machines from the same package. Erlang is installed either as 32 and 64 bit. So, RabbitMQ could be easily installed in the Windows operating system. Let's install these stuff for running RabbitMQ.

Firstly, we should install Erlang runtime environment to our Windows. Erlang has Windows installers for 32 bits and 64 bits as shown in the previous image. We shall easily download the related binary file to our computer, and install Erlang using it.

Installation of Erlang in Windows

After installing the Erlang runtime environment, we've completed the requirements of RabbitMQ installation. The next step is to download and install the RabbitMQ binary file with related Windows version.

Installation of Erlang in Windows

We can find the related Windows installer for RabbitMQ with the help of RabbitMQ download webpage as seen in the screenshot showing the download webpage of RabbitMQ. Then, we just need to click and install the RabbitMQ on our Windows computer. Besides installing using installer, we can install using the Windows binary file that is served within the RabbitMQ download webpage. Following instructions would be enough for installing RabbitMQ without installer:

  • Download binary file for RabbitMQ Windows Binary Files
  • Extract the downloaded RabbitMQ zip file to our local folder

Both ways are possible to install the RabbitMQ on your Windows computer. Note that you may add the RabbitMQ binaries directory to the windows system path in the system/environment variable settings.

Mac OS X installation

As we specified that we have one requirement to install RabbitMQ on our computers. In Mac OS X, we have package managers and we have the opportunity to compile from source for both Erlang runtime environment and RabbitMQ.

Firstly, both Erlang and RabbitMQ can be easily installed on Mac OS X using package managers. Although, we have lots of package managers on Mac OS X, Homebrew and MacPort are the mostly used in Mac OS X. So, we'll talk about the installation using Homebrew and MacPorts.

Firstly, Homebrew has both RabbitMQ and Erlang on its repository. As RabbitMQ has a dependency with Erlang, Homebrew finds its dependent software and install them together.

Homebrew is just another package manager for Mac OS X. Homebrew is so easy to install on Mac OS X and Homebrew has lots of packages so, you would find your application in its repository. Check it out:

So, we just need to install RabbitMQ in Homebrew using following command on our terminal as shown in the following image:

brew install rabbitmq

Homebrew Installation of RabbitMQ

MacPorts has the similar method of operation with Homebrew. MacPorts also installs the software with its dependencies. Therefore, we just need to install RabbitMQ in MacPorts using the following command on our terminal as shown in the following image:

port install rabbitmq-server

MacPorts Installation of RabbitMQ

Secondly, we have another opportunity to install RabbitMQ and Erlang with compiling the source codes in Mac OS X. Before compiling we need the following to compile Erlang source code:

  • GNU make
  • GNU C compiler
  • Perl 5

After downloading and unzipping the source codes of the Erlang, we just need common commands on the Erlang folder for compiling from source code such as:

make install

Finally, we just need to download and unzip RabbitMQ binary files.


Ubuntu is just another Linux distribution based on Debian. As we explained the installation instructions on the Mac OS X, the similar instructions would be applied for the Ubuntu, too.

Ubuntu has package manager called Advanced Packaging Tool (apt-get) and has Debian package manager called dpkg. So, we are able to install RabbitMQ and Erlang runtime environment using apt-get. Moreover, similar in Mac OS X, we are able to compile from source codes of Erlang.

Firstly, as we said in the previous paragraph, we can install RabbitMQ using apt-get and dpkg. Before installing RabbitMQ, we should add RabbitMQ repository to APT repository using following line (Add following line to /etc/apt/sources.list):

deb testing main

Then, we are ready for installing RabbitMQ and its dependency Erlang runtime environment as seen in the Image 10:

sudo apt-get install rabbitmq-server

Ubuntu Installation of RabbitMQ

Also, we have dpkg dependency management tool for installing RabbitMQ. RabbitMQ has packages for dpkg in its download webpage. We can download it from its website then run the following command:

dpkg –i rabbitmq-server.deb 

Secondly, we have another option, which was explained in the Mac OS X topic. That is, compiling from source codes. We just need to compile the downloaded Erlang source code then, we are ready for running the downloaded binary files of RabbitMQ. You can look at the details in the Mac OS X topic.


Fedora is yet another Linux distribution based on Red Hat. Installation instructions of Fedora are similar to Ubuntu's installation. Fedora has package managers called rpm and yum.

Firstly, we are able to install RabbitMQ with its dependency Erlang using package managers. Before using yum, we should run the following command to add RabbitMQ repository:

wget -O /etc/yum.repos.d/epel-erlang.repo

Then, we can install RabbitMQ using the following command as seen in the Image 11:

sudo yum install rabbitmq-server

Fedora Installation of RabbitMQ

Fedora has another package manager, which comes from Red Hat, called rpm[AK1] . As RabbitMQ publishes package as rpm, we can easily install using rpm package manager. After downloading the rpm package from RabbitMQ webpage, we can install RabbitMQ with Erlang, using following command:

rpm –ivh rabbitmq-server.rpm

Secondly, we have another option, which was explained in the Mac OS X topic. That is compiling from source codes. We just need to compile the downloaded Erlang source code then, we are ready for running the downloaded binary files of RabbitMQ. You can look at the details in the Mac OS X topic.

Amazon elastic compute cloud (EC2) installation

Amazon Web Services (AWS) is cloud-computing platform offered from Amazon. AWS has lots of features for developers such as autoscaling. Besides RabbitMQ, AWS also offers their own messaging service called Simple Queue Service: however, RabbitMQ has lots of advantages over Amazon SQS. For instance, RabbitMQ has an extendable plugin system whereas SQS capabilities are short. RabbitMQ implements standard approach to message acknowledgement and consumption whereas SQS has its own standards.

Anyway, we can easily install our RabbitMQ to AWS EC2 instance and we can save images of RabbitMQ installed operating system. In AWS EC2, we choose one of the operating systems from the list or any other instance that we used before.

Amazon EC2 would be a good choice for your servers. In a scalable architecture, we need clusters of Message Brokers, databases, and caches and so on. EC2 gives you great API and it's really quite easy to create clusters using EC2.

As we explained that we are able to install RabbitMQ on Windows, Linux and Mac OS X, we just need to follow the instructions for AWS EC2 that are well explained in the preceding topics.

Amazon EC2

Starting RabbitMQ

As we see that installation part of the RabbitMQ is so easy, starting RabbitMQ is as similar as its installation. Some package managers in Linux and Mac OS X and Windows installer add configuration parameters to operation system's configuration for automatically starting. In such a case, we don't need to run RabbitMQ command manually; however, if we install RabbitMQ manually, we need to run RabbitMQ commands manually.

Starting RabbitMQ in Windows

If we use Windows installer of RabbitMQ, installer already makes configurations for starting automatically. Therefore, we don't need to run RabbitMQ manually; however, whenever we'd like to control the status of server, we just need to run following command on the sbin folder of RabbitMQ as shown in the following image:

rabbitmqctl status

Status of RabbitMQ in Windows

May be you installed RabbitMQ manually on your Windows and you wonder that how you can run the RabbitMQ server. You should run the following command to start the RabbitMQ (you have to run this command with Administrative user). Moreover, you can install RabbitMQ server as a windows service.


Other OS (Linux, Mac OS X)

There's isn't much difference in running RabbitMQ on Windows and other operating systems. If we installed using package managers like apt-get, yum, and so on, we don't need to run the RabbitMQ manually because RabbitMQ has already started automatically. So, we'd like to check the status of the RabbitMQ using the following command as shown in the following image:

sudo rabbitmqctl status

Status of RabbitMQ in Unix

After controlling the RabbitMQ status, if we get a message that says that RabbitMQ isn't running, then we should run the RabbitMQ using the following command on the sbin folder of RabbitMQ installation folder as seen in the Image 15:


Starting of RabbitMQ in Unix


We finally finished our article which introduces messaging concepts along with brief details about Message Queue and Message Brokers, and the protocol called AMQP that defines the functionalities of Message Queue. Finally, our article introduces the RabbitMQ, providing information about its installation on different types of operating systems and how we run the RabbitMQ server.

Resources for Article:

Further resources on this subject:

You've been reading an excerpt of:

Mastering RabbitMQ

Explore Title