views:

105

answers:

1

How Can i check whether a message Queue already exists or not.. Reason for this is i have 2 different applications one creating a queue and other reading from that queue..So if i run the Client which reads from the queue first than it crashes. So to avoid that i would like to check first whether the queue exists or not

+3  A: 

Don't bother checking.

queue.declare is an idempotent operation. So, if you run it once, twice, N times, the result will still be the same.

If you want to ensure that the queue exists, just declare it before using it. Make sure you declare it with the same durability, exclusivity, auto-deleted-ness every time, otherwise you'll get an exception.

If you actually do need to check if a queue exists (you shouldn't normally need to), do a passive declare of the queue. That operation succeeds if the queue exists, or fails in an error if it doesn't.

scvalex
Can you please Mention the Syntax for declaring the queue passively in c# api
Jigar Sheth
Use IModel.QueueDeclare and set passive to true. http://www.rabbitmq.com/releases/rabbitmq-dotnet-client/v1.8.1/rabbitmq-dotnet-client-1.8.1-client-htmldoc/html/type-RabbitMQ.Client.IModel.html
scvalex
i did declare the queue before using it..worked fine..thanks
Jigar Sheth