ActiveMQ排队消息java servicemix-karaf命令



我正在使用ActiveMQ ServiceMix,并且我希望在java中有入队消息计数/出队消息计数等。我想要ActiveMQ控制台中显示的值

Name    Number Of Pending Messages      Number Of Consumers     Messages Enqueued       Messages Dequeued       Views       Operations  
Consumer.ID-10-147-244-247-15461c6c293-38-0.Vir...  0   2   13  13  
Consumer.ID-10-147-244-247-15470570c61-108-0.Vi...  0   2   13  13

我想获得排队的消息列:)

我的程序开始与消费者和听众的会话。一切都很好。

但为了监控,我写了一个karaf命令,调用我的订阅对象(订阅包含会话/连接/队列等)

在我的订阅中,我尝试了这个:

ActiveMQConnection activeMQConnection = ((ActiveMQConnection) connection);
ActiveMQQueue activeMQQueue = getQueueConnection(queueName, activeMQConnection);
ActiveMQTopic a = AdvisorySupport.getConsumerAdvisoryTopic(activeMQQueue);

但接下来我不知道如何获得DestinationStatistics来获得关于我的队列/主题的所有信息。。。

我也试试这个:

QueueBrowser queueBrowser = session.createBrowser(activeMQQueue);

但浏览器中没有任何干扰。

如果有人能帮我获取DestinationStatistics对象;)

非常感谢

最后我使用QueueBrowser来知道队列的长度,QueuBrowser只浏览队列而不删除它们,这样我就可以迭代和计算任何队列中的消息数量。

最新更新