Get Queues in RabbitMQ

Get Queues in RabbitMQ

A queue in RabbitMQ is a buffer that stores messages until they are processed by consumers. Producers send messages to queues, and consumers retrieve and process them asynchronously. Knowing a list of queues can be useful for monitoring and managing the setup. This tutorial explains how to get queues in RabbitMQ.

1. CLI

To list queues in RabbitMQ, use the rabbitmqctl command as follows:

sudo rabbitmqctl -s list_queues -p testing

This command lists all queues in the testing virtual host along with their message counts. Example output:

test_queue_1 10
test_queue_2 0

2. HTTP API

RabbitMQ's management plugin provides an HTTP API to retrieve queue details. You can query queues using curl:

curl -u guest:guest http://localhost:15672/api/queues/testing

The part of the output:

[
  {
    ...
    "messages": 10,
    "name": "test_queue_1",
    "state": "running",
    "vhost": "testing"
  },
  {
    ...
    "messages": 0,
    "name": "test_queue_2",
    "state": "running",
    "vhost": "testing"
  }
]

This API response provides details about queues in the testing virtual host.

Leave a Comment

Cancel reply

Your email address will not be published.