2017-08-31 214 views
0

我有一個使用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;

+0

謝謝,但我需要從Java應用程序去做,而不是控制檯(並通過控制檯它似乎是一個緩慢的查詢)。 – jandres

+0

messageCount方法不適用於我,它始終返回0消息。有關更多信息,我正在使用Spring-amqp框架。 – jandres