2017-08-31 216 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