Reputation: 4296
The docs for amqplib (AMQP 0-9-1 NodeJS API) describe the functionality for
Channel#checkQueue
as follows...
Check whether a queue exists. This will bork the channel if the named queue doesn’t exist; if it does exist, you go through to the next round!
Assuming I understand the meaning of "bork the channel" correctly as "take down the channel", then what is this function good for? It seems very misleading to phrase it as "checkQueue" if it isn't a safe check.
Similarly, for Channel#checkExchange
Check that an exchange exists. If it doesn’t exist, the channel will be closed with an error. If it does exist, happy days.
Am I missing something or is this almost useless? I guess the channel can be recreated but not without loss of channel scoped activity.
Upvotes: 2
Views: 1008
Reputation: 19
Based on my research (building a RabbitMQ client for production use), your assertion is correct: checkQueue
and checkExchange
are both completely useless.
The established amqplib pattern is to always use assertQueue
instead.
Assert a queue into existence. This operation is idempotent given identical arguments; however, it will bork the channel if the queue already exists but has different properties (values supplied in the arguments field may or may not count for borking purposes; check the borker’s, I mean broker’s, documentation).
As you can see, there are a couple of drawbacks to using assertQueue
- even though it is an idempotent operation:
exclusive
, durable
, autodelete
, messageTtl
, expires
, etc.Upvotes: 1