Introduction to RabbitMQ with Nodejs

Narongsak Keawmanee
3 min readJan 25, 2020

--

On this series. I will write the simple application that using RabbitMQ with NodeJs by using publish/subscribe queue that provide by RabbitMQ. this application will send list of url through RabbitMQ. after RabbitMQ got message will process one list at a time by fire request to that url and get response back to user.

What is RabbitMQ

RabbitMQ is message queueing. it will make sure every message send from sender to receiver 100%. it lightweight and pretty easy to insall. it also can select type of message queue like send to specific receiver or send to all receiver. this is the type of message queue.

Type of Queue

On RabbitMQ have so many thing to learn. one of them is type of queue. the way to sending message. please checkout at RabbitMQ Toturials section of documentation and play it.

Install RabbitMQ on Ubuntu server.

For this article. I will created one server on DigitalOcean to be host of RabbitMQ. I will create droplet with ubuntu 18.04.3. After server is up. I will install Erlang frist because RabbitMQ use Erlang to run. I will import Erlang GPG key frist by this command.

wget -O- https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | sudo apt-key add -echo "deb https://packages.erlang-solutions.com/ubuntu bionic contrib" | sudo tee /etc/apt/sources.list.d/rabbitmq.list

Then install Erlang

sudo apt update
sudo apt -y install erlang

Then check is Erlang install by running this command

erl

If Erlang install success. it will show message like this.

Erlang/OTP 22 [erts-10.6.2] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1]Eshell V10.6.2  (abort with ^G)

After that. we install RabbitMQ by import RabbitMQ first

wget -O- https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc | sudo apt-key add -wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -echo "deb https://dl.bintray.com/rabbitmq/debian $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/rabbitmq.list

Then install.

sudo apt update
sudo apt -y install rabbitmq-server

After that. check status rabbitmq running by using.

systemctl is-enabled rabbitmq-server.service

It should enable. if not let start rabbitmq by using.

sudo systemctl enable rabbitmq-server

After that we will turn on management dashboard for easy manage monitor by using this command.

sudo rabbitmq-plugins enable rabbitmq_management

it should enable rabbitmq dashboard. we will check port runing by.

ss -tunelp | grep 15672

Then typing your ip address following with port like this

http://<your-server-ip>:15672

It will show rabbitmq page like this.

we will set username password by using this command

rabbitmqctl add_user admin <your-strong-password>
rabbitmqctl set_user_tags admin administrator

Then login. you will see dashboard like this.

We are successfully install RabbitMQ.

What Next?

After this we will start coding. but it will be in next article. so please follow me and when new article arrive. you will not missing it.

I appreciated all cup of coffee. you can donate coffee at button below.

https://www.buymeacoffee.com/klogic

--

--

Narongsak Keawmanee

Software Engineer at Refinitiv • Highly ambitious • Love working with great people • Never Stop Learning