Listing all queues in ActiveMQ

This still has an issue with getting a consistent read. I will update this once I figure that piece out…

import org.apache.activemq.*;
import java.util.*;
import org.apache.activemq.advisory.DestinationSource;

import javax.jms.*;
import javax.naming.*;

import org.apache.activemq.*;
import org.apache.activemq.command.ActiveMQQueue;

public class ListQueues {
  public static void main(String[] args) throws  Exception {
    String user = "admin";
    String password = "***********";
    String url = "failover:(tcp://cmhlpromsesb02:61616,tcp://cmhlpromsesb01:61616)";
    ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(user,password,url);
    ActiveMQConnection conn = (ActiveMQConnection)connectionFactory.createConnection();

    DestinationSource destSource = conn.getDestinationSource();
    Set queues = destSource.getQueues();
    System.out.println("Found '" + queues.size() + "' queues");

    for(ActiveMQQueue queue : queues) {

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.