Is it possible to view the contents of a RabbitMQ message directly from the command line?

Can I view the contents of a RabbitMQ message directly from the command line?

sudo rabbitmqctl list_queues lists the queues.

Is there any command like sudo rabbitmqctl list_queue_messages queue_name ?

+82
rabbitmq rabbitmqctl rabbitmqadmin
May 22 '12 at 20:18
source share
5 answers

You must enable the management plugin.

 rabbitmq-plugins enable rabbitmq_management 

See here:

http://www.rabbitmq.com/plugins.html

But for the specifics of management.

http://www.rabbitmq.com/management.html

Finally, after installation, you will need to follow the instructions below to install and use the rabbitmqadmin tool. Which can be used for full interaction with the system. http://www.rabbitmq.com/management-cli.html

For example:

 rabbitmqadmin get queue=<QueueName> requeue=false 

will give you the first message from the queue.

+87
May 22 '12 at 9:27
source share

Here are the commands I use to get the contents of the queue:

RabbitMQ version 3.1.5 for Linux using https://www.rabbitmq.com/management-cli.html

Here are my exchanges:

 eric@dev ~ $ sudo python rabbitmqadmin list exchanges +-------+--------------------+---------+-------------+---------+----------+ | vhost | name | type | auto_delete | durable | internal | +-------+--------------------+---------+-------------+---------+----------+ | / | | direct | False | True | False | | / | kowalski | topic | False | True | False | +-------+--------------------+---------+-------------+---------+----------+ 

Here is my turn:

 eric@dev ~ $ sudo python rabbitmqadmin list queues +-------+----------+-------------+-----------+---------+------------------------+---------------------+--------+----------+----------------+-------------------------+---------------------+--------+---------+ | vhost | name | auto_delete | consumers | durable | exclusive_consumer_tag | idle_since | memory | messages | messages_ready | messages_unacknowledged | node | policy | status | +-------+----------+-------------+-----------+---------+------------------------+---------------------+--------+----------+----------------+-------------------------+---------------------+--------+---------+ | / | myqueue | False | 0 | True | | 2014-09-10 13:32:18 | 13760 | 0 | 0 | 0 |rabbit@ip-11-1-52-125| | running | +-------+----------+-------------+-----------+---------+------------------------+---------------------+--------+----------+----------------+-------------------------+---------------------+--------+---------+ 

Drag and drop some objects into myqueue:

 curl -i -u guest:guest http://localhost:15672/api/exchanges/%2f/kowalski/publish -d '{"properties":{},"routing_key":"abcxyz","payload":"foobar","payload_encoding":"string"}' HTTP/1.1 200 OK Server: MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact) Date: Wed, 10 Sep 2014 17:46:59 GMT content-type: application/json Content-Length: 15 Cache-Control: no-cache {"routed":true} 

RabbitMQ see messages in the queue:

 eric@dev ~ $ sudo python rabbitmqadmin get queue=myqueue requeue=true count=10 +-------------+----------+---------------+---------------------------------------+---------------+------------------+------------+-------------+ | routing_key | exchange | message_count | payload | payload_bytes | payload_encoding | properties | redelivered | +-------------+----------+---------------+---------------------------------------+---------------+------------------+------------+-------------+ | abcxyz | kowalski | 10 | foobar | 6 | string | | True | | abcxyz | kowalski | 9 | {'testdata':'test'} | 19 | string | | True | | abcxyz | kowalski | 8 | {'mykey':'myvalue'} | 19 | string | | True | | abcxyz | kowalski | 7 | {'mykey':'myvalue'} | 19 | string | | True | +-------------+----------+---------------+---------------------------------------+---------------+------------------+------------+-------------+ 
+36
Sep 10 '14 at 17:37
source share

I wrote rabbitmq-dump-queue , which allows you to send messages from the RabbitMQ queue to local files and rewrite messages in the original order.

Usage example (for outputting the first 50 messages of the incoming_1 queue):

 rabbitmq-dump-queue -url="amqp://user:password@rabbitmq.example.com:5672/" -queue=incoming_1 -max-messages=50 -output-dir=/tmp 
+16
Nov 12 '14 at 2:32
source share

You can use the RabbitMQ API for counting or messages:

 /api/queues/vhost/name/get 

Receive messages from the queue. (This is not an HTTP GET, as it will change the state of the queue.) You should publish the body as follows:

 {"count":5,"requeue":true,"encoding":"auto","truncate":50000} 

count controls the maximum number of messages to receive. You may receive fewer messages than this if the queue cannot immediately provide them.

Requeue determines whether messages will be removed from the queue. If the props is true, they will be queued - but their delivery flag will be set. the encoding must be either "auto" (in this case, the payload will be returned as a string if it is valid UTF-8 code, and base64 is encoded otherwise), or "base64" (in this case the payload will always be encoded in base64 ) If truncation is present, it truncates the message payload if it is larger than the specified size (in bytes). truncation is optional; all other keys are required.

Please note that the publishing / receiving paths in the HTTP API are for implementing test messages, diagnostics, etc. - they do not provide reliable delivery and therefore should be considered as a sysadmin tool, and not as a general messaging API.

http://hg.rabbitmq.com/rabbitmq-management/raw-file/rabbitmq_v3_1_3/priv/www/api/index.html

+7
Jul 15 '16 at 7:22
source share

a bit late, but rabbitmq has a built-in trace that allows you to see incoming messages in the log. When enabled, you can simply tail -f/var/tmp/rabbitmq-tracing/.log (on Mac) to view the messages.

detailed description here http://www.mikeobrien.net/blog/tracing-rabbitmq-messages

+4
Feb 02 '16 at 15:33
source share



All Articles