0
0
RabbitmqHow-ToBeginner ยท 3 min read

How to List Exchanges in RabbitMQ: Commands and Examples

To list all exchanges in RabbitMQ, use the rabbitmqctl list_exchanges command in the terminal or view them in the RabbitMQ Management UI under the Exchanges tab. The CLI command shows exchange names and types quickly.
๐Ÿ“

Syntax

The basic command to list exchanges in RabbitMQ is rabbitmqctl list_exchanges [options]. You can add specific fields to display, such as name and type.

Example fields: rabbitmqctl list_exchanges name type

This command connects to the RabbitMQ server and prints a list of all exchanges with the requested details.

bash
rabbitmqctl list_exchanges [field1] [field2] ...
๐Ÿ’ป

Example

This example shows how to list all exchanges with their names and types using the RabbitMQ CLI tool.

bash
rabbitmqctl list_exchanges name type
Output
amq.direct direct amq.fanout fanout amq.headers headers amq.match headers amq.rabbitmq.trace fanout amq.topic topic
โš ๏ธ

Common Pitfalls

One common mistake is running rabbitmqctl commands without proper permissions or without the RabbitMQ server running, which causes errors.

Another is forgetting to specify fields, which still works but shows default columns that might not be useful.

Also, mixing up exchanges with queues can confuse beginners; exchanges route messages, queues store them.

bash
Wrong:
rabbitmqctl list_queues

Right:
rabbitmqctl list_exchanges name type
๐Ÿ“Š

Quick Reference

CommandDescription
rabbitmqctl list_exchangesLists all exchanges with default fields
rabbitmqctl list_exchanges name typeLists exchanges showing their names and types
rabbitmqctl list_exchanges name type durableLists exchanges with durability status
rabbitmqctl list_queuesLists queues (not exchanges)
Access Management UIView exchanges under the Exchanges tab in the RabbitMQ web UI
โœ…

Key Takeaways

Use 'rabbitmqctl list_exchanges name type' to see all exchanges and their types.
Ensure RabbitMQ server is running and you have proper permissions before running commands.
Exchanges are different from queues; use the correct command to list each.
RabbitMQ Management UI provides a user-friendly way to view exchanges visually.
Specifying fields in the command helps get focused information about exchanges.