amqplib icon indicating copy to clipboard operation
amqplib copied to clipboard

Reuse existing exchanges, maybe also queues ?

Open djhojd opened this issue 12 years ago • 3 comments

Hi guys,

I would really appreciate if anyone would answer/solve my issue that I have (maybe others do too): so, if I have two different code locations, different servers maybe, where I need to use the same exchange or queue, do I need to know the exact configuration to be able to use it? if this is normal, why is it bad to just do a GET exchangeName/queueName and, if exists, use the result? What is the best practice when trying to use an existing exchange/queue?

Thanks

djhojd avatar Oct 16 '14 16:10 djhojd

@djhojd simply declare them again, declare operations with the same properties are idempotent.

michaelklishin avatar Oct 16 '14 19:10 michaelklishin

I need to use the same exchange or queue, do I need to know the exact configuration to be able to use it?

Yes, in general, you have to get all the properties right when declaring exchanges and queues. There is no "GET" operation as such.

There are variations of {Queue,Exchange}Declare that only check that the named object exists (ignoring its properties); these will fail, invalidating the channel, if the named object doesn't exist. In the amqplib API they are available as Channel#checkQueue(name) and Channel#checkExchange(name).

squaremo avatar Oct 16 '14 23:10 squaremo

I thought there wasn't another way but had to ask the experts :) Thanks again and love this library! :+1:

djhojd avatar Oct 17 '14 08:10 djhojd