I run RabbitMQ image in docker-compose like this:
version: '2.2'
services:
rabbitmq:
networks:
- private
image: rabbitmq:3.8.0-beta.3-management
ports:
- 15672:15672
Then connect to via other Node.js app like this:
const amqp = require('amqplib');
this._connection = await amqp.connect(xxxxxx);
console.log(this._connection.blocked);
this._connection.on("blocked", (reason) => {
console.log("!!!! connection blocked");
});
It works fine but few questions:
- Why
console.log(this._connection.blocked);
outputsundefined
; - How do I detect that connection is already blocked when I start the client? I.e. service is out of resources and RabbitMA manager says that connection is in 'blocking' state right after it connected. This is why
this._connection.on("blocked"
doesn't work