【问题标题】:RabbitMQ and queue dataRabbitMQ 和队列数据
【发布时间】:2018-02-09 08:00:14
【问题描述】:

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

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

谢谢

【问题讨论】:

    标签: rabbitmq


    【解决方案1】:

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

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

    尝试使用:

    channel.messageCount(you_queue)

    看看它是否适合你

    /** * Returns the number of messages in a queue ready to be delivered * to consumers. This method assumes the queue exists. If it doesn't, * an exception will be closed with an exception. * @param queue the name of the queue * @return the number of messages in ready state * @throws IOException Problem transmitting method. */ long messageCount(String queue) throws IOException;

    【讨论】:

    • 谢谢,但我需要从 Java 应用程序中完成,而不是通过控制台(通过控制台,这似乎是一个缓慢的查询)。
    • messageCount 方法对我不起作用,它总是返回 0 条消息。有关更多信息,我正在使用 Spring-amqp 框架。
    猜你喜欢
    • 2021-06-14
    • 2018-10-18
    • 1970-01-01
    • 2015-03-31
    • 1970-01-01
    • 1970-01-01
    • 2014-05-21
    • 1970-01-01
    • 2013-04-19
    相关资源
    最近更新 更多