Question

When you subscribe to an exclusive queue (only one consumer allowed at a time), node-amqp throws an exception when the queue is oversubscribed (already has a consumer).

  • I've tried using the .on("error",cb) syntax.
  • I've tried error domains (node 0.10.0)
  • Try/catch obviously didn't work

Here's my subscription line, but it's nothing special:

queue.subscribe({ack: true, prefetchCount: 1, exclusive: exclusive}, cbExecute).addCallback((ok) -> listeners[type] = ok.consumerTag);

You get an unhandled exception thrown when queue is in use:

ACCESS_REFUSED - queue 'respQ' in vhost 'brkoacph' in exclusive use

Looking inside node-amqp I see that they implement an independent task queue inside the module so that when the error occurs, the task is running in an independent context.

Is there any work-around/fix? ...or am I just doing something wrong?

Was it helpful?

Solution

I think what you want to do is to catch the errors in the AMQP connection. As you mentioned, node-amqp captures errors in a different context, but you can listen to then on the connection:

yourConnectionVar.on( 'error', function(err) {
  //do something
  console.log('An error occurred' + err);
});

I hope this helps.

Cheers!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top