English 中文(简体)
能否直接从命令线上查看 RabitMQ 信件内容?
原标题:Is it possible to view RabbitMQ message contents directly from the command line?

能否直接从命令线上查看 RabitMQ 信件内容?

sudo rabidmqctl list_queues 列出队列 。

是否有类似 sudo raidmqctl list_queue_ messsages & lt; queue_ name> 这样的命令?

问题回答

您应该启用管理插件 。

rabbitmq-plugins enable rabbitmq_management

见此:

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

以及这里的 管理细节。

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

Finally once set up you will need to follow the instructions below to install and use the rabbitmqadmin tool. Which can be used to fully interact with the system. http://www.rabbitmq.com/management-cli.html

例如:

rabbitmqadmin get queue=<QueueName> requeue=false

将给您队列中的第一个消息 。

以下是我用来获取队列内容的命令 :

RabbitMQ 3.1.5 关于使用https://www.rabbitmq.com/management-cli.html

以下是我的交换:

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

这是我的队列:

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

将一些物品埋入细列中:

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}

RabitMQ 在队列中看到信件 :

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

我写了>rabbittmq-dump-queue ,允许将RabbitMQ队列中的信息倾弃到本地文件并按原始顺序重新排队。

示例用法( 倾弃前50条队列中 < code> coming_ 1 头50条信息) :

rabbitmq-dump-queue -url="amqp://user:[email protected]:5672/" -queue=incoming_1 -max-messages=50 -output-dir=/tmp

如果您想要从队列中获取多个消息, 请说 10 条, 使用的命令是 :

rabbitmqadmin get queue=<QueueName> ackmode=ack_requeue_true count=10

http://localhost:15672:

如果您不想将信件重新排队, 请将 ackmode 更改为 ack_ requeue_ false

稍晚一点, 但是是的 rabbentmq 有在跟踪器中的构建, 允许您在日志中看到连接信件 。 启用后, 您可以只使用 < code>tail -f/ var/ tmp/ rabbbitmq- ttracing/. log (在 mac) 来查看信件 。

详细解码于此 < a href=" "http://www.mikeobrien.net/blog/ttracting-rabbitmq-mesages" rel= "no follown noreferrer" >http://www.mikeobrien.net/blog/ttracing-rabbittmq-mesages





相关问题
what the default max length of rabbit queue

For any given queue, the maximum length (of either type) can be defined using a policy (this option is highly recommended) or by clients using the queue s optional arguments. In the case where both ...

Retrieve messages from RabbitMQ queue(s)

I m looking to implement RabbitMQ into my PHP application, and am using the php-amqp extension. My only question is this, how do I easily query to return the contents of the queue in PHP? php-amqp ...

How to use listen on basic.return in python client of AMQP

I d like to make sure that my message was delivered to a queue. To do so I m adding the mandatory param to the basic_publish. What else should I do to receive the basic.return message if my message ...

Is AMQP production ready?

I d like to use AMQP to join two services one written in C# and other written in python. I m expecting quite large volume of messages per second. Is there any AMQP Broker that is production ready? ...

Multiple consumer one queue

Is it possible to make multiple consumers to share one single queue in RabbitMQ? I am currently using this php library to work with RabbitMQ, from what I observe, although I have 2 identical instances ...

Why use AMQP/ZeroMQ/RabbitMQ

as opposed to writing your own library. We re working on a project here that will be a self-dividing server pool, if one section grows too heavy, the manager would divide it and put it on another ...

How to wait for messages on multiple queues using py-amqplib

I m using py-amqplib to access RabbitMQ in Python. The application receives requests to listen on certain MQ topics from time to time. The first time it receives such a request it creates an AMQP ...

热门标签