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

后端 未结 6 1474
Happy的楠姐
Happy的楠姐 2020-12-22 17:54

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

sudo rabbitmqctl list_queues lists the queues.

Is there any comma

6条回答
  •  忘掉有多难
    2020-12-22 18:32

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

    RabbitMQ version 3.1.5 on Fedora 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 queue:

    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 |
    +-------+----------+-------------+-----------+---------+------------------------+---------------------+--------+----------+----------------+-------------------------+---------------------+--------+---------+
    

    Cram some items 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 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        |
    +-------------+----------+---------------+---------------------------------------+---------------+------------------+------------+-------------+
    

提交回复
热议问题