[rabbitmq-discuss] Passive queue declaration and channel closure

Simon MacMullen simon at rabbitmq.com
Fri Feb 17 12:31:36 GMT 2012

On 16/02/12 17:10, Busoli, Simone wrote:
> Hi, I’m revamping this
> <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2011-February/011314.html>
> old thread because I’m trying to solve pretty much the same problem. I
> need to know whether a queue that I have declared still exists on the
> server or has for any reason been deleted.
> Without relying on the management plugin I think the only way to do that
> is to declare the queue as passive.


> At least with the .NET client and
> apparently the Java client too, when the queue does not exist, besides
> throwing an exception, the channel is closed as well.

It's the server closing the channel really. The channel closure causes 
the exception to be thrown, not the other way around.

> From the spec:
> If set, the server will reply with Declare-Ok if the queue already
> exists with the same name, and raise an error if not. The client can use
> this to check whether a queue exists without modifying the server state.
> There is no mention of channel closure, while the last sentence implies
> that using the passive bit is indeed a way for a client to check queue
> existence, so closing the channel when it doesn’t is a bit unexpected.

The key phrase is "raise an error". This is defined to always close the 
channel (and sometimes the connection too depending on the error code) 
in AMQP.

> That said, it’s not a big deal to recreate the channel in such cases,
> but I’d appreciate your opinion. Any chance this behavior can be changed
> in the client libraries?

It's probably slightly easier to open a new channel just to issue the 
queue.declare then close it anyway. That's what I'd do.

It's not really the client's purview, and currently the only way for the 
server to indicate an error is to close *something* anyway, so this 
isn't a trivial change...

Cheers, Simon

Simon MacMullen
RabbitMQ, VMware

More information about the rabbitmq-discuss mailing list