node-amqp queue destroyed: notifications to subscribers

344 views Asked by At

I am using node-amqp and rabbit for some pub/sub tools. I would like to know if it is possible to notify subscribers when someone/something (in other process) has destroyed the queue where they are listening.

For example, process one:

connection.queue(name = "test-queue1", options, function(queue) {

 queue.subscribe({}, function(message, headers, deliveryInfo) {
   deliverMessage(message);
 }).once('error', function(error) {
   logger.error(error)
 }).once("queueDeleteOk", function bindHandler() {
  queue.close();
});

};

Now, other process could destroy that queue. How the subscribers will know about that?. For example, process two could do:

connection.queue(name = "test-queue1", options, function(queue) {
   queue.destroy(delete_options);
}).once("queueDeleteOk", function bindHandler() {
  queue.close();
});

I have tried to listen the event "queueDeletedOk" that works, but it is emitted and received only in the process two, which is destroying the queue. The same happens trying the event "close" over the queue.

thanks and best regards,

1

There are 1 answers

1
old_sound On

RabbitMQ supports consumer cancel notifications: http://www.rabbitmq.com/consumer-cancel.html

I don't know about the library you are using, but this one here [1] is created by a former RabbitMQ core-dev, and supports consumer cancel notifications.

1 - http://squaremo.github.io/amqp.node/doc/channel_api.html