Reuse existing exchanges, maybe also queues ?
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 simply declare them again, declare operations with the same properties are idempotent.
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).
I thought there wasn't another way but had to ask the experts :) Thanks again and love this library! :+1: