This will provide the list of queues and topics managed by an ActiveMQ broker…
import javax.jms.*; import java.io.*; import java.util.*; import org.apache.activemq.*; import org.apache.activemq.command.*; import org.apache.activemq.advisory.*; public class GetDestinations { private static String url = ActiveMQConnection.DEFAULT_BROKER_URL; public static void main(String[] args) throws Exception { ActiveMQConnectionFactory connectionFactory=new ActiveMQConnectionFactory("admin", "password", "failover:(tcp://esb01:61616,tcp://esb02:61616)"); ActiveMQConnection connection = (ActiveMQConnection)connectionFactory.createConnection(); Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE); connection.start(); DestinationSource dest = connection.getDestinationSource(); Setamqt = dest.getTopics(); System.out.println(amqt); Iterator queues2 = amqt.iterator(); while (queues2.hasNext()) { ActiveMQTopic queue3 = queues2.next(); System.out.println(new Date() + "\t" + "Topic: " + queue3.getPhysicalName()); } Set amqs = dest.getQueues(); System.out.println(amqs); Iterator queues = amqs.iterator(); while (queues.hasNext()) { ActiveMQQueue queue2 = queues.next(); System.out.println("Queue: " + queue2.getPhysicalName()); } } }