0
0
RabbitmqHow-ToBeginner ยท 3 min read

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_queues specify 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 rabbitmqctl without 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

CommandDescription
rabbitmqctl list_queuesLists all queues with default details
rabbitmqctl list_queues name messagesLists queue names and message counts
rabbitmqctl list_queues name consumersLists queue names and number of consumers
rabbitmqctl -n list_queuesLists queues on a specific RabbitMQ node
Access Management UI > Queues tabVisual 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.