How to properly work with RabbitMQ in NodeJS as a producer?

33 Views Asked by At

Should I keep the connection open always or is it better to connect and disconnect only when a message is added to the queue?

If i keep the connection open at all times, the connection disconnects after about 1 hour.

enter image description here

I connect as follows:

const connection = await amqp.connect(`${this._options.url}?heartbeat=30`, { timeout: 30000, keepAlive: true  });

How to make the connection reconnect automatically?

0

There are 0 best solutions below