Rabbit MQ

Snehil Verma
Snehil Verma
Published in
1 min readNov 19, 2019

Rabbit MQ is a message scheduling service. I implemented it with node.js in my code with the help of the amqp library. Amqp library uses the AMQP protocol which is a messaging protocol.

Last Month I was trying to implement rabbit MQ service with node js. When I started implementing the service I came through a problem that whenever the function was called a new channel was initialized by the sender. Although nothing was there that was braking the code, according to the rabbit MQ documentation, there must be only one channel allocated to a single process in node.js.

To solve the above problem I created a cannel while starting the project and initialize it to be global. This can be one way of creating a singleton connection in node.js, the other was is to initialize the connection in the starting and then pass it down in the files where you call it. Since I’m lazy to write down extra lines of code I initialized it to be global.

The receiver end of the rabbit MQ is pretty sorted, all you need is to write a listener for each queue in the channel and then initialize it at the starting of the queue. This will start the listener and it will listen until your app is closed.

Here are few blogs to follow for rabbit MQ implementation:-

  1. https://www.rabbitmq.com/tutorials/tutorial-one-javascript.html
  2. https://medium.com/better-programming/implementing-rabbitmq-with-node-js-93e15a44a9cc

--

--