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:
console.log(this._connection.blocked);
outputs undefined
;this._connection.on("blocked"
doesn't workI have check the document and source of amqplib, register event callback is the only way to receive Blocked Connection Notifications
, amqplib connection hasn't use some member variable to show blocking state.
From offical document, I am not sure whether this mean there is no notification when you connect to an already blocked server:
If before the connections are unblocked the node also starts running low on disk space, another connection.blocked will not be sent