[rabbitmq-discuss] How to check if an exchange exists

Simon MacMullen simon at rabbitmq.com
Wed Jul 14 10:38:05 BST 2010

On 13/07/10 16:40, alcalino wrote:
> I would want to ask you how can you check if an exchange exists using the
> java client api. I know ho to check if a queue exists before trying to
> declare it (using queueDeclarePasive) but i don't know / understand how to
> do it with the exchanges (using exchangeDeclarePasive). Thanks,

Hi Francisco. exchangeDeclarePassive should work exactly like 
queueDeclarePassive - i.e. either succeeds or closes the channel.

If you just want to ensure the exchange exists before publishing to it, 
you should actively declare it - that's idempotent so you don't need to 
worry about doing it more than once.

Cheers, Simon

Simon MacMullen
Staff Engineer, RabbitMQ
SpringSource, a division of VMware

More information about the rabbitmq-discuss mailing list