Getting Started With RabbitMQ in 10 Minutes
RabbitMQ is one of the most popular opensource message broker/Queuing engine available in the market..
It has been used as communication(Message Oriented) bridge in many software architectures.. Communication between Microservices is one of the obvious use case where we can use MQ to make things simple .. RabbitMQ makes communication between services easy with it's simple messaging system.. Rabbit MQ supports multiple protocols like AMQP
In one of our projects, We've used it to delegate the heavy processing things to worker process written in python form single threaded NodeJs process.. thus it makes easy to scale our services and opened the doors to polyglot architecture for our services... we enjoyed it a lot.. So I thought to write a simple article which will help people to get start with RabbitMQ in 10 minutes..
Installing RabbitMQ (In Ubuntu based systems)
First update source-list and add signing key
sudo apt update
wget -O - 'https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc' | sudo apt-key add -
Now add repository to source list
echo "deb https://dl.bintray.com/rabbitmq/debian $(lsb_release -cs) main erlang" | sudo tee /etc/apt/sources.list.d/bintray.rabbitmq.list
Now update the source list and install the RabbitMQ ....
sudo apt update
sudo apt install rabbitmq-server -y
The server is started as a daemon by default when the RabbitMQ is installed.
Verify the installation.. with the following command...
sudo systemctl status rabbitmq-server.service
And also I'll show you small how to with NodeJS and RabbitMQ.. for this you need to have Node installed in your system.. If you haven't installed NodeJs you can check the instructions here..
First you need to install amqplib.. it's RabbitMQ client for NodeJs..
npm install amqplib
Then create two files named.. sender.js and receiver.js
Now you can run the receiver.js and and publisher.js and you can see the output like one shown below...
node sender.js
node receiver.js
If you want to use it with other languages.. please check official guide.. https://www.rabbitmq.com/getstarted.html
That's it for now.. If you like.. don't forget to share it guys.. You can follow us on fb.com/opensourceinside and also subscribe our channel on Youtube..