How to List Channels in RabbitMQ: Commands and Examples
To list channels in RabbitMQ, use the
rabbitmqctl list_channels command in the terminal or access the Management HTTP API endpoint /api/channels. These methods show active channels with details like connection, user, and state.Syntax
The primary command to list channels in RabbitMQ is rabbitmqctl list_channels [options]. This command outputs active channels with default columns like pid, connection_name, and state.
You can specify columns to display by adding their names after the command, for example: rabbitmqctl list_channels pid connection_name user.
Alternatively, use the Management HTTP API GET request to /api/channels to get JSON data about channels.
bash
rabbitmqctl list_channels [column1] [column2] ...
Example
This example shows how to list all active channels with their process ID, connection name, user, and state using rabbitmqctl. It also shows how to get channel info via the Management API using curl.
bash
rabbitmqctl list_channels pid connection_name user state
# Example curl command to get channels via HTTP API
curl -u guest:guest http://localhost:15672/api/channelsOutput
Listing channels ...
<1234.5678.9> 127.0.0.1:5672 -> 127.0.0.1:12345 guest running
<1234.5678.10> 127.0.0.1:5672 -> 127.0.0.1:12346 guest running
[
{
"name": "<1234.5678.9>",
"user": "guest",
"state": "running",
"connection_name": "127.0.0.1:5672 -> 127.0.0.1:12345"
},
{
"name": "<1234.5678.10>",
"user": "guest",
"state": "running",
"connection_name": "127.0.0.1:5672 -> 127.0.0.1:12346"
}
]
Common Pitfalls
- Running
rabbitmqctl list_channelswithout sufficient permissions may fail; run as a user with RabbitMQ admin rights. - Using the command on a remote server requires SSH access or running it locally.
- Management API requires the management plugin enabled and correct credentials.
- Not specifying columns shows default columns only, which might miss needed details.
bash
Wrong: rabbitmqctl list_channels Right: rabbitmqctl list_channels pid connection_name user state
Quick Reference
| Command / API | Description |
|---|---|
| rabbitmqctl list_channels | Lists active channels with default columns |
| rabbitmqctl list_channels pid user state | Lists channels with specified columns |
| curl -u user:pass http://localhost:15672/api/channels | Fetches channels info via HTTP API in JSON |
| rabbitmq-plugins enable rabbitmq_management | Enable management plugin to use HTTP API |
Key Takeaways
Use 'rabbitmqctl list_channels' to see active channels from the command line.
Specify columns after the command to customize output details.
The Management HTTP API '/api/channels' provides channel info in JSON format.
Ensure you have proper permissions and the management plugin enabled.
Use 'curl' with credentials to access channel info via HTTP API.