Book Image

Mastering RabbitMQ

By : Yusuf Aytas, Emrah Ayanoglu, Dotan Nahum
Book Image

Mastering RabbitMQ

By: Yusuf Aytas, Emrah Ayanoglu, Dotan Nahum

Overview of this book

RabbitMQ is one of the most powerful Open Source message broker software, which is widely used in tech companies such as Mozilla, VMware, Google, AT&T, and so on. RabbitMQ gives you lots of fantastic and easy-to-manage functionalities to control and manage the messaging facility with lots of community support. As scalability is one of our major modern problems, messaging with RabbitMQ is the main part of the solution to this problem This book explains and demonstrates the RabbitMQ server in a detailed way. It provides you with lots of real-world examples and advanced solutions to tackle the scalability issues. You’ll begin your journey with the installation and configuration of the RabbitMQ server, while also being given specific details pertaining to the subject. Next, you’ll study the major problems that our server faces, including scalability and high availability, and try to get the solutions for both of these issues by using the RabbitMQ mechanisms. Following on from this, you’ll get to design and develop your own plugins using the Erlang language and RabbitMQ’s internal API. This knowledge will help you to start with the management and monitoring of the messages, tools, and applications. You’ll also gain an understanding of the security and integrity of the messaging facilities that RabbitMQ provides. In the last few chapters, you will build and keep track of your clients (senders and receivers) using Java, Python, and C#.
Table of Contents (18 chapters)
Mastering RabbitMQ
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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 can be found in the download webpage of the RabbitMQ website, as shown in the following image:

Download Webpage of RabbitMQ

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

Download Webpage of Erlang

Now, let's to talk about the installation of both RabbitMQ and Erlang on Windows, Mac OS X, Ubuntu, Fedora, and Amazon Web Services.

Windows

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

Firstly, we should install the Erlang runtime environment on Windows. Erlang has Windows installers for 32-bit and 64-bit as shown in the previous image. We can 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 the Windows version:

Installation of Erlang in Windows

We can find the related Windows installer for RabbitMQ with the help of RabbitMQ download webpage as shown 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 the installer, we can install using the Windows binary file that is served within the RabbitMQ download webpage. The following instructions will be enough for installing RabbitMQ without the installer:

  • Download the binary file for RabbitMQ Windows binary files

  • Extract the downloaded RabbitMQ zip file to our local folder

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

Mac OS X

As we specified, we only 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 the 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 ones that are mostly used in Mac OS X. So, we'll talk about the installation using Homebrew and MacPorts.

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

Note

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

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

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 port install rabbitmq-server command on our terminal, as shown in the following image:

MacPorts Installation of RabbitMQ

Another way to install RabbitMQ and Erlang is by compiling the source codes in Mac OS X. Before compiling, we need the following to compile Erlang source code:

  • The GNU make

  • The 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, as follows:

./configure
make
make install

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

Ubuntu

Ubuntu is just another Linux distribution based on Debian. Similar instructions as the ones we discussed for the installation on the Mac OS X would be applied for Ubuntu.

Ubuntu has a package manager called Advanced Packaging Tool (apt-get) and has a Debian package manager called dpkg. So, we are able to install RabbitMQ and Erlang runtime environment using apt-get. Moreover, similar to Mac OS X, we can 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 the RabbitMQ repository to the APT repository using the following line (add the following line to /etc/apt/sources.list):

deb http://www.rabbitmq.com/debian/ testing main

Now, we are ready to install RabbitMQ and its dependency Erlang runtime environment, as shown in the following image:

sudo apt-get install rabbitmq-server

Ubuntu Installation of RabbitMQ

Also, we have the 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, and we are ready to run the downloaded binary files of RabbitMQ. You can look at the details in the Mac OS X section.

Fedora

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 http://repos.fedorapeople.org/repos/peter/erlang/epel-erlang.repo

Then, we can install RabbitMQ using the following command as shown in the following screenshot:

sudo yum install rabbitmq-server

Fedora Installation of RabbitMQ

Fedora has another package manager, which comes from Red Hat, called rpm. As RabbitMQ publishes package as rpm, we can easily install using the 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 code. We just need to compile the downloaded Erlang source code and we are ready to run the downloaded binary files of RabbitMQ. You can look at the details in the Mac OS X section.

Amazon elastic compute cloud (EC2)

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 a standard approach to message acknowledgement and consumption, whereas SQS has its own standards.

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

Tip

Amazon EC2 would be a good choice for your servers. In a scalable architecture, we need clusters of Message Brokers, databases, caches, and so on. EC2 gives you great API, and it's really quite easy to create clusters using EC2. We will talk about the clusters of RabbitMQ using EC2 in Chapter 4, Clustering and High Availability.

As we explained, 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 explained well in the preceding sections. Let's take a look at the following screenshot:

Amazon EC2