RESOURCE_LOCKED - cannot obtain exclusive access to locked queue 'replies' in vhost 'orders'.
It could be originally declared on another connection or the exclusive property value does not
match that of the original declaration.
An exclusive queue belongs to the connection that declared it. Any other connection that tries to use it gets this error. Here is what is refused, what is not, and the part that costs messages, measured on RabbitMQ 4.3.6.
| From a second connection | Result |
|---|---|
| passive declare | RESOURCE_LOCKED |
basic_consume | RESOURCE_LOCKED |
| publish to the queue | allowed; the message arrives |
So a second instance of a service that declares the same exclusive queue name fails on start-up, while publishers elsewhere keep sending to it without noticing anything.
When the owning connection closes, the queue is deleted, with everything in it. In our test the queue held a message published from another connection; after the owner disconnected, a passive declare answered NOT_FOUND - no queue. A restart, a network blip or a pod rescheduled is enough.
Exclusive queues are made for state that may disappear: RPC reply queues, temporary subscriptions. For work that must survive the consumer, use a durable, non-exclusive queue. If you only want one consumer at a time, use a single active consumer (x-single-active-consumer) instead.
A normal queue with an exclusive consumer refuses a second consumer with a different code:
ACCESS_REFUSED - queue 'orders.work' in vhost 'orders' in exclusive use
Here the queue survives when the consumer goes; only the consumption is exclusive.