Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Curl to get Rabbitmq queue size

Tags:

Is there a way to get the size (remaining messages) of a queue in rabbitmq with a simple Curl?

Something like curl -xget http://host:1234/api/queue/test/stats

Thank you

like image 775
tbo Avatar asked Jun 25 '14 07:06

tbo


People also ask

How do I check my RabbitMQ queue size?

The API documentation is installed along with the RabbitMQ management console and should be available on that server at http://MY_RABBITMQ_SERVER:15672/api . Show activity on this post. I was able to get the size/depth of queue from python program.

How big can RabbitMQ queue be?

Define Max Queue Length Using a Policy When the 1MiB limit is reached, the oldest messages are discarded from the head of the queue.

How do I know if my RabbitMQ queue is empty?

In php-amqlib: $channel->basic_get(QUEUE_NAME, true); // the second arg is no_ack . The second argument marks that no acknowledgment is expected for that message. That is, you don't have to "flag" the message as read for RabbitMQ to confidently dequeue it.

How many messages can a RabbitMQ queue hold?

Queues are single-threaded in RabbitMQ, and one queue can handle up to about 50 thousand messages.


2 Answers

Finally I did the trick with the following:

curl -s -i -u guest:guest http://host:port/api/queues/vhost/queue_name | sed 's/,/\n/g' | grep '"messages"' | sed 's/"messages"://g'
like image 161
tbo Avatar answered Sep 25 '22 13:09

tbo


As much as I love hacky sed one-liners this is probably the cleanest solution:

curl -s -u <user>:<password> http://<host>:<port>/api/queues/<virtual-host>/<queue> | jq .messages
like image 20
gabrielson Avatar answered Sep 25 '22 13:09

gabrielson