Bootstrap FreeKB - RabbitMQ - Resolve "cannot obtain exclusive access to locked queue"
RabbitMQ - Resolve "cannot obtain exclusive access to locked queue"

Updated:   |  RabbitMQ articles

Let's say something like this is being captured in rabbit.log.

2022-04-08 18:58:24.037 [warning] <0.16434.227> Error purging queue: cannot obtain exclusive access to locked queue 'amq.gen-q8gYvM_2dovjoQPkC-V2HA' in vhost 'foo'.
It could be originally declared on another connection or the exclusive property value does not match that of the original declaration.

 

There are a few things that could cause this to occur, such as:

 

This typically suggests that a dynamic shovel was created to move messages from an exchange to a queue.

 

If the shovel source is an exchange, an exclusive queue will be created and the source exchange should be bound to the exclusive queue. An exclusive queue is a sort of temporary queue that will be removed after the shovel is terminated. The exclusive queue will begin with "amq.gen". The rabbitmqctl list_queues command can be used to list the exclusive queues. In this example, there is an exclusive queue in the foo virtual host.

~]$ rabbitmqctl list_queues name exclusive --vhost foo --formatter json | python -m json.tool
[
    {
        "exclusive": true,
        "name": "amq.gen-q8gYvM_2dovjoQPkC-V2HA"
    }
]

 

Likewise, the rabbitmqctl list_bindings command should show that the source exchange is bound to the exclusive queue.

~]# rabbitmqctl list_bindings --vhost foo --formatter json | python -m json.tool
[
    {
        "arguments": [],
        "destination_kind": "queue",
        "destination_name": "amq.gen-q8gYvM_2dovjoQPkC-V2HA",
        "routing_key": "key002",
        "source_kind": "exchange",
        "source_name": "exchange001"
    }
]

 

The rabbitmq shovel_status command can be used to check the state of the shovel.

~]$ rabbitmqctl shovel_status --formatter json | python -m json.tool
[
    {
        "destination": "amqps://rabbit.example.com:5671/%2f",
        "destination_protocol": "amqp091",
        "destination_queue": "queue001",
        "last_changed": "2022-04-03 03:49:29",
        "name": "shovel001",
        "source": "amqps://rabbit.example.com:5671/%2f",
        "source_exchange": "exchange001",
        "source_exchange_key": "key002",
        "source_protocol": "amqp091",
        "state": "running",
        "termination_reason": "",
        "type": "dynamic",
        "vhost": "foo"
    }
]

 

Sometimes, you might just want to restart the shovel to see if this has any impact.

rabbitmqctl restart_shovel --vhost foo shovel001

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter c64def in the box below so that we can be sure you are a human.