rabbitmqctl list_queues: Queue Depth Checks
rabbitmqctl list_queues name messages consumers prints the depth and consumer count of every queue, run from inside the broker node.
Unlike rabbitmqadmin (HTTP), rabbitmqctl connects to the Erlang node directly. It works without the management plugin, which makes it handy inside the broker container in CI.
What it does
rabbitmqctl is the node control tool. list_queues prints per-queue metrics; you choose the columns (name, messages, messages_ready, messages_unacknowledged, consumers). It connects to the local RabbitMQ node using the shared Erlang cookie, so it must run on (or be pointed at) the broker node.
Common usage
rabbitmqctl list_queues name messages consumers
# restrict to a vhost
rabbitmqctl list_queues -p /my-vhost name messages
# run inside the broker container
docker exec rabbitmq rabbitmqctl list_queues name messages_readyOptions
| Flag / col | What it does |
|---|---|
| list_queues [cols...] | Choose columns to print |
| -p <vhost> | Restrict to a virtual host |
| messages | Total messages (ready + unacked) |
| messages_ready | Messages ready for delivery |
| messages_unacknowledged | Delivered but not yet acked |
| consumers | Number of consumers on the queue |
In CI
Run it via docker exec into the broker container so the Erlang cookie and node name match; running it from a separate container without the same cookie fails. It is a good post-test assertion: check messages_ready is 0 to prove your consumer drained the queue.
Common errors in CI
"Error: unable to perform an operation on node ... Hostname mismatch" or "Could not decrypt ... erlang cookie" means the cookie or node name does not match; exec into the actual broker node instead. "Error: {:badrpc, :nodedown}" means the broker is not fully started; wait for it. An empty result usually means the wrong -p vhost.