How to List Queues in RabbitMQ: Commands and Examples
To list queues in RabbitMQ, use the
rabbitmqctl list_queues command in the terminal or access the RabbitMQ Management UI and navigate to the Queues tab. The CLI command shows queue names and details, while the UI provides a visual list with more info.Syntax
The basic command to list queues in RabbitMQ is rabbitmqctl list_queues. You can add optional parameters to show specific queue details like message counts or consumers.
rabbitmqctl: The command-line tool to control RabbitMQ.list_queues: The action to list all queues.- Optional fields after
list_queuesspecify what details to show, e.g.,name messages consumers.
bash
rabbitmqctl list_queues [name messages consumers]
Example
This example shows how to list all queues with their names and the number of messages they hold using the CLI.
bash
rabbitmqctl list_queues name messages
Output
queue1 5
queue2 0
queue3 12
Common Pitfalls
Common mistakes when listing queues include:
- Running
rabbitmqctlwithout proper permissions or as a non-root user may fail. - Not specifying the correct node if RabbitMQ runs in a cluster; use
-n <node_name>option. - Expecting output without starting the RabbitMQ server first.
- Confusing the CLI output format; it uses tab-separated values.
bash
Wrong: rabbitmqctl list_queues Right: sudo rabbitmqctl list_queues name messages
Quick Reference
| Command | Description |
|---|---|
| rabbitmqctl list_queues | Lists all queues with default details |
| rabbitmqctl list_queues name messages | Lists queue names and message counts |
| rabbitmqctl list_queues name consumers | Lists queue names and number of consumers |
| rabbitmqctl -n | Lists queues on a specific RabbitMQ node |
| Access Management UI > Queues tab | Visual list of queues with detailed info |
Key Takeaways
Use
rabbitmqctl list_queues to see all queues from the command line.Add fields like
name and messages to customize output details.Ensure RabbitMQ server is running and you have proper permissions before running commands.
Use the RabbitMQ Management UI for an easy visual way to list and inspect queues.
Specify the node with
-n if working in a clustered RabbitMQ setup.