I\'m trying to figure out how to get a list of existing queues on a remote broker.
It looks like I can listen to queues as they are created/destroyed by adding an ad
// 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();
}
}
See this answer: https://stackoverflow.com/a/14021722/3735747
If you're doing this in Java, there's the DestinationSource class that will help: http://activemq.apache.org/maven/5.7.0/activemq-core/apidocs/org/apache/activemq/advisory/DestinationSource.html
Create a connection and use the ActiveMQConnection type instead of the JMS Connection type.
// Create a ConnectionFactory
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
// Create a Connection
ActiveMQConnection connection = (ActiveMQConnection) connectionFactory.createConnection();
Once you're connected, you can create a DestinationSource object and get the queues:
DestinationSource ds = connection.getDestinationSource();
Set<ActiveMQQueue> queues = ds.getQueues();
for(ActiveMQQueue queue : queues){
try {
System.out.println(queue.getQueueName());
} catch (JMSException e) {
e.printStackTrace();
}
}