获取RabbitMQ队列中的消息数

获取RabbitMQ队列中的消息数,第1张

获取RabbitMQ队列中的消息数

使用皮卡:

import pikapika_conn_params = pika.ConnectionParameters(    host='localhost', port=5672,    credentials=pika.credentials.PlainCredentials('guest', 'guest'),)connection = pika.BlockingConnection(pika_conn_params)channel = connection.channel()queue = channel.queue_declare(    queue="your_queue", durable=True,    exclusive=False, auto_delete=False)print(queue.method.message_count)

使用PyRabbit:

from pyrabbit.api import Clientcl = Client('localhost:55672', 'guest', 'guest')cl.get_messages('example_vhost', 'example_queue')[0]['message_count']

使用HTTP

句法

curl -i -u user:password http://localhost:15672/api/queues/vhost/queue

例:

curl -i -u guest:guest http://localhost:15672/api/queues/%2f/celery

注意:默认虚拟主机是

/
需要转义
%2f

使用CLI:

$ sudo rabbitmqctl list_queues | grep 'my_queue'


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5617058.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-15
下一篇2022-12-15

发表评论

登录后才能评论

评论列表(0条)

    保存