5/19/16

RabbitMQ installation or build from source

How to install or build RabbitMQ from Source code


Hi Friends,

In this tutorial i am demoing you step by step procedure to install RabbitMQ from source code.
For those who have not used this before, lets see few things about RabbitMQ

RabbitMQ


RabbitMQ is messaging queue for one application to talk to other application or applications. Like any other queue it works on First in First out (FIFO) principal.
One application works as sender and pushes messages to the queue.
Other application working as receiver will take message out from the queue called pop operation.

RabbitMQ is written in Erlang programming language. RabbitMQ is heighly scalable.

Use Case : When to use RabbitMQ


RabbitMQ is used in cases where we want to achieve non-blocking communication between apps. Sender application may have fast or slow speed to pushing messages to the queue or also it can have variable speed depending upon the application load. This also happens on the receiver side where consuming (pop operation of queue) message from the queue can vary in speed.

To build greater understanding let's have a scenario :-
Bob is helping his friend John in building a wall. So John is building a wall and Bob is passing bricks to John.



Bob has lots of bricks lying at his end. Bob will throw brick to John, which John will receive and put on the wall.
Now if Bob has more speed in throwing brick then Bob has to wait until John is free to receive. Vice versa, if Bob is tired and has slow speed in throwing bricks then John will wait. In both the cases either one is waiting for other and blocked. This flow of communication is blocking.

To avoid this blocking of Bob (Message Sender Application) or John (Message Receiver Application) lets put a bucket (RabbitMQ) in between. For sake of this example we assume that bucket is accessible from both end (Bob and John) and enough is size.

Bob can throw bricks to this bucket at his speed. And John also can receive bricks from this bucket at his speed. This flow is not blocking any of them.

How RabbitMQ Works


RabbitMQ works on Client - Server model. You need to have RabbitMQ server running on any machine (Linux, Unix, Mac or Windows). You will have a client written in any language. You can find RabbitMQ client written in almost any language you want.

Producer - Consumer Case

Here we have a classic case of Producer - Consumer problem where both can differ in speed and load. In Producer - Consumer we avoid direct contact between both to avoid blocking flow.
And to avoid this blocking we use some data-structure or database, to store communication messages.
By implementing such approach we make this flow non-blocking.

In our example given above, Bob is throwing bricks in bucket so he is working as someone who is producing bucket items (Producer). And John is taking bricks from the bucket so he is acting as Consumer of bucket items.

Installing RabbitMQ from Source Code


Now you have enough idea about RabbitMQ. Lets focus on rabbitmq-server installation now :-

I am using following configuration :-

  • RabbitMQ version 3.6.0
  • Ubuntu version 14.04 LTS
  • Erlang Version 18.2

Step 1:-

Download and install required dependencies like

  • python 2 mostly comes with ubuntu so check first
  • import simplejson.py library into python
  • erlang
  • GNU make
  • libxslt
  • xmlto
  • zip and unzip

Step 2:-

Download / Clone source code from git repository

git clone https://github.com/rabbitmq/rabbitmq-server.git

Now

cd rabbitmq-server
sudo make
sudo make install
cd scripts

Step 3:-

We will also be using web-admin panel. We need to enable the plugin required for web-admin panel (rabbitmq-management plugin)

sudo ./rabbitmq-plugins list



This will show you modules available for you to enable.

You need to enable module rabbitmq-management


sudo ./rabbitmq-plugins enable rabbitmq-management

If it says you do not have directory and file under /etc then please create required structure. Try again.
If not then you will see some additional plugins that are enabled for rabbitmq-management.

Step 4:-

Start rabbitmq server by using command below

sudo ./rabbitmq-server



Step 5:-

Check if rabbitmq-server is running

sudo ./rabbitmqctl status




To Stop RabbitMQ server use

sudo ./rabbitmqctl stop

You nee to choose client of your choice to connect and use the queue. There is help and examples available on how to use RabbitMQ clients .

So i am not covering client usages in this tutorial.

Supported Operation and basics

Click here to learn more about working with queues in RabbitMQ.
https://www.rabbitmq.com/getstarted.html