5

Using AMQP module for Node JS and RabbitMQ, is there any way to tell how many subscribers there are on a queue?

We have multiple queues on the default exchange for multiple regions. When one region is down, instead of routing messages to that queue, we'll instead route to the next-best AMQP queue (region) that is actively listening.

Is there any way to count the number of subscribers on a queue?

We have a heartbeat set up so the server should be able to track accurately.

Thanks!

Chris Nolet
  • 8,714
  • 7
  • 67
  • 92

1 Answers1

3

I ended up figuring out this piece of gold:

var conn = amqp.createConnection({ url: process.env.AMQP, heartbeat: 60 });

conn.queue('queue-name').on('queueDeclareOk', function(args) {
  console.log('Total Consumers: ' + args.consumerCount);
}

Works perfectly :)

Chris Nolet
  • 8,714
  • 7
  • 67
  • 92