我正在试图找出如何获取远程代理上的现有队列列表.
看起来我可以通过添加咨询消息(我还没有工作)来创建/销毁它们来侦听队列,但我需要在启动时获得所有现有队列.
看起来我可以使用getDestinationMap来做到这一点:
http://activemq.apache.org/maven/apidocs/org/apache/activemq/broker/region/Region.html#getDestinationMap()
但这似乎只能从嵌入式和进程中的代理调用.
我的意思是......我愿意走这条路,但似乎更有意义的是为activemq设置正常的init/daemon,然后让远程进程像普通的JMS使用者一样连接到它.
该文档似乎暗示它是可能的:
http://activemq.apache.org/how-can-i-see-what-destinations-are-used.html
但这是通过使用Region对象,只有在与activemq位于同一JVM中时才有可能.
// Create a ConnectionFactory ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616"); // Create a Connection ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection(); //Important point that was missed in the above answer connection.start(); DestinationSource ds = connection.getDestinationSource(); Set<ActiveMQQueue> queues = ds.getQueues(); for(ActiveMQQueue queue : queues){ try { System.out.println(queue.getQueueName()); } catch (JMSException e) { e.printStackTrace(); } }