On 06/02/15 14:48, Ján Kianička wrote:
> Dear RabbitMQ (python pika) Users,
> I wanted to implement following scenarion:
> 1. Check if the exchange exists.
> 2. Report about existence.
> 3. Create missing exchange.
> 4. Check if queue exists.
> 5. Report about existence and if it does not exists, create it.
This is not the AMQPish way to do it - the intent is that you should use
exchange.declare / queue.declare to state what you need, and the server
will create it transparently if needed. 99% of the time you don't need
to explicitly check if something exists, especially if your intent is to
create it if it doesn't.
> For checking I have used exchange, queue declare method with
> passive=True. This method raise the channel exception with reply code
> 404 (not found).
Yes.
> But then when I have tried to use the channel again for declaring the
> queue with passive=False, there came error from pika:
Once you have received a channel exception, that channel is dead. You
need to create another one.
(But really, just declare your queues / exchanges and proceed).
Cheers, Simon