获取ActiveMQ中的队列名称列表 [英] Get list of queue names in ActiveMQ

查看:1878
本文介绍了获取ActiveMQ中的队列名称列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用下面的代码来获取ActiveMQ中的队列列表。但它不起作用。我的ActiveMQ中有4个队列。

I have tried below code to get list of queues in ActiveMQ. But its not working. I have 4 queues in my ActiveMQ.

try {
ActiveMQConnection.makeConnection(URL).start();
Set<ActiveMQQueue> allque= ActiveMQConnection.makeConnection().getDestinationSource().getQueues();

Iterator<ActiveMQQueue> itr= allque.iterator();
while(itr.hasNext()){
ActiveMQQueue q= itr.next();
System.out.println(q.getQueueName());
}
} catch (Exception e) {

e.printStackTrace();
}

请告诉我代码中的任何更正或一些新代码完成。

Please let me know any correction in my code or some new code get it done.

推荐答案

目标源功能不是保证在Broker上查找目的地的方法。在许多情况下,该功能可能无法提供任何结果,例如,当Broker上的顾问功能被禁用或客户端已配置为不查看建议时。您还可以立即查询目的地,这不一定允许从Broker将顾问分派到客户端所需的时间。

The Destination Source functionality is not a guaranteed way to find the destinations on the Broker. The functionality can fail to provide any results in a number of cases such as when the advisory feature on the Broker is disabled or the client has been configured not to watch for advisories. You also query for destination immediately which doesn't necessarily allow for the time needed for the advisories to be dispatched to the client from the Broker.

更可靠的机制是在Broker上 JMX支持,提供获取目的地列表的方法以及许多其他信息。正在运行的代理实例。

A more reliable mechanism is the JMX support on the Broker which provides methods for obtaining lists of destinations along with a host of other information about the running broker instance.

有很多文章显示了如何在ActiveMQ中使用JMX。

There are plenty of articles out there showing how to use JMX with ActiveMQ.

这篇关于获取ActiveMQ中的队列名称列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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