How can I check whether a RabbitMQ message queue exists or not?

This won't work in situations when there is someone else (other application) responsible for q declaration. And I simply could not know all the parameters of the q, just the name.

I would rather use passiveDeclare and check for the IOException that the q does not exists


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.