2016-11-07 50 views
0

我想要在java中获取activeMQ队列的所有名称,我发现了几个主题herehere关于该问题以及人们建议使用我无法导入的DestinationSource在Eclipse中编写代码时。我试过了:在java中获取activemq的所有队列名称

import org.apache.activemq.advisory.DestinationSource; 

我使用java 1.7和最新的activemq版本5.14.1。任何观点,如果destinationsource仍然支持或不支持? 谢谢,

回答

0

ActiveMQ项目中仍然支持该功能,但需要注意的是,它可能并不总是基于here的注释工作。如果您在代理上启用了咨询支持,那么它应该为您提供一些对存在目标的洞察,尽管JMX会为您提供更多的目标管理。

unit tests显示您可以引用的DestinationSource功能。您需要将'activemq-client'jar放在类路径中,因此您的IDE项目可能没有正确配置。

0

处理这些信息的最简单方法是使用默认安装的Jolokia。要做到这一点,使用HTTP客户端发出GET请求以下URI之一:

http://localhost:8161/api/jolokia/search/*:destinationType=Queue,* 
http://localhost:8161/api/jolokia/search/*:destinationType=Topic,* 

您需要在JMX用户名和密码来传递(默认:行政/管理)作为HTTP的一部分请求。该系统将与沿东西线回应:

{ 
    "request" : { 
    "mbean" : "*:destinationType=Queue,*", 
    "type" : "search" 
    }, 
    "status" : 200, 
    "timestamp" : 1478615354, 
    "value" : [ 
    "org.apache.activemq:brokerName=localhost,destinationName=systemX.bar,destinationType=Queue,type=Broker", 
    "org.apache.activemq:brokerName=localhost,destinationName=systemX.foo,destinationType=Queue,type=Broker", 
    "org.apache.activemq:brokerName=localhost,destinationName=ActiveMQ.DLQ,destinationType=Queue,type=Broker" 
    ] 
} 

上面显示了队列systemX.foosystemX.barActiveMQ.DLQ。下面是一个使用curl命令这个示例:

curl -u admin http://localhost:8161/api/jolokia/search/*:destinationType=Queue,* && echo "" 

有关如何使用API​​的椒,指the documentation一个很好的解释。

相关问题