RabbitMQ is an open source message broker software that implements the Advanced Message Queuing Protocol (AMQP) , the emerging standard for high performance enterprise messaging. It is one of the most popular message broker solutions in the market, offered with an open-source license (Mozilla Public License v1.1) as an implementation of AMQP developed using the Erlang language, which is actually relatively easy to use and get started. The RabbitMQ server is a robust and scalable implementation of an AMQP broker. AMQP is a widely accepted open-source standard for distributing and transferring messages from a source to a destination. As a protocol and standard, it sets a common ground for various applications and message broker middle wares to inter operate without encountering issues caused by individually set design decisions.
RabbitMQ Server concepts:
Following are some important concepts that we needs to define before we start RabbitMQ installation setup. The default virtual host, the default user, and the default permissions are used in the examples that follow, but it is still good to have a feeling of what it is.
Producer: Application that sends the messages.
Consumer: Application that receives the messages.
Queue: Buffer that stores messages.
Message: Information that is sent from the producer to a consumer through RabbitMQ.
Connection: A connection is a TCP connection between your application and the RabbitMQ broker.
Channel: A channel is a virtual connection inside a connection. When you are publishing or consuming messages or subscribing to a queue is it all done over a channel.
Exchange: Receives messages from producers and pushes them to queues depending on rules defined by the exchange type. In order to receive messages, a queue needs to be bound to at least one exchange.
Binding: A binding is a link between a queue and an exchange.
Routing key: The routing key is a key that the exchange looks at to decide how to route the message to queues. The routing key is like an address for the message.
virtual host: A Virtual host provide a way to segregate applications using the same RabbitMQ instance. Different users can have different access privileges to different vhost and queues and exchanges can be created so they only exists in one vhost.
Our first step is to make sure that all system packages are up-to-date by running the following apt-get commands in command line terminal.
# apt-get update
# apt-get upgrade
After system update, we need to get main dependencies of RabbitMQ such as Erlang. Let's use the below command to get Erlang on our Ubuntu 16.04 server.
# apt-get install -y erlang
Installing RabbixMQ Server on Ubuntu 16.04
Installing rabbitmq-server package on Ubuntu 16.04 is simple. Just flow the below command and type 'Y' key to continue installing RabbixMQ servger package along with its required dependencies.
# apt-get install rabbitmq-server
Starting RabbixMQ Services:
RabbitMQ server has been installed on Ubuntu 16.04, now run below commands to start and check the status of RabbitMQ server and to enable its services to auto start after each reboot.
# systemctl enable rabbitmq-server
# systemctl start rabbitmq-server
# systemctl status rabbitmq-server
Enabling RabbitMQ Management console
RabbitMQ server is up and running, now are going to show you that how you can setup its Web Management console by using the rabbitmq-management plugin. Rabbitmq-management plugin allows you to manage and monitor your RabbitMQ server in a variety of ways, such as listing and deleting exchanges, queues, bindings and many more.
Let's run the below command to install this plugin on your Ubuntu 16.04 server.
# rabbitmq-plugins enable rabbitmq_management
The rabbitmq_management plugin is a combination of the following plugins which will be enabled after executing above command.
Now we can access RabbitMQ Management console from our web browser, available on HTTP port 15672 by default. You can also create new admin user using below commands.
# rabbitmqctl add_user radmin radmin
# rabbitmqctl set_user_tags radmin administrator
# rabbitmqctl set_permissions -p / radmin ".*" ".*" ".*"
Now open below URL along with the default port and login with your newly create user and password. You can also use the default 'guest' user name and 'guest' password to login.
Using RabbitMQ Web Console:
Welcome to the RabbitMQ Web management console, after providing the right user login details can manage your RabbitMQ server from your web.
Running rabbitmq-server in the foreground displays a banner message, and reports on progress in the startup sequence, concluding with the message "broker running", indicating that the RabbitMQ broker has been started successfully. RabbitMQ is a fully-fledged application stack (i.e. a message broker) that gives you all the tools you need to work with, instead of acting like a framework for you to implement your own. I hope you find this article much helpful and interesting. Do not forget to share it with your friends.