RabbitMQ 和队列数据 [英] RabbitMQ and queue data

查看:98
本文介绍了RabbitMQ 和队列数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 RabbitMQ 的应用程序,我在其中使用 HTTP API (/api/queues/vhost/name) 获取 Rabbit 队列中的消息数.但是,此信息似乎会不时刷新(默认情况下每 5 秒刷新一次).我以为信息总是最新的,而且是管理页面在给定的时间间隔内更新.

I have an application with RabbitMQ where I get the number of messages in a Rabbit queue using the HTTP API (/api/queues/vhost/name). However, it appears that this information is refreshed from time to time (by default every 5 seconds). I thought the information was always up to date, and it was the administration page that was updated in a given interval.

有什么方法可以实时获取队列中的消息数量?

Is there any way to get the number of messages in a queue with real-time information?

谢谢

推荐答案

管理数据库默认每 5 秒更新一次.

The management database is updated each 5 seconds by default.

使用命令行rabbitmqctl list_queues 获取实时值.

use the command line rabbitmqctl list_queues for real-time values.

尝试使用:

<代码>channel.messageCount(you_queue)

看看它是否适合你

<代码>/*** 返回队列中准备发送的消息数* 给消费者.此方法假定队列存在.如果没有,* 一个异常将被一个异常关闭.* @param queue 队列名称* @return 就绪状态的消息数* @throws IOException 传输方法有问题.*/long messageCount(String queue) throws IOException;

这篇关于RabbitMQ 和队列数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆