Question

Could someone please explain the use of the parameter isExclusive of the constructor for the type EasyNetQ.Topology.Queue.

Note: This type needs to be instantiated for deleting a queue using the Advanced API.

Was it helpful?

Solution

From the AMQP docs

"Exclusive queues may only be accessed by the current connection, and are deleted when that connection closes. Passive declaration of an exclusive queue by other connections are not allowed."

It's a good idea to check that the queue exists before deleting it. Doing a passive declare (which won't create the queue if it doesn't exist) will return an IQueue instance that you can then use to delete it and you don't have to worry about the isExclusive parameter:

// may throw if queue doesn't exist
var queue = advancedBus.QueueDeclare("my.queue.name", passive = true);
advancedBus.QueueDelete(queue);

As an aside. The isExclusive parameter of IQueue isn't used in the IAdvancedBus.Delete(..) method, so you can happily ignore it (with the caveat that this might change in future versions).

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