protected Set<String> queryQueueNames (String location, String brokerName, String queueNamePattern) throws Exception {
        Set<String> result = new TreeSet<>();

        if ( location.equals("*") ) {
            // TBD222: stop using address (aka location) as the registry key
            for ( String oneLocation : this.brokerRegistry.keys() ) {
                result.addAll(this.queryQueueNames(oneLocation, brokerName, queueNamePattern)); // RECURSION
            }
        } else {
            if ( brokerName.equals("*") ) {
                String[] brokerNames = this.queryBrokerNames(location);

                for ( String oneBrokerName : brokerNames ) {
                    result.addAll(this.queryQueueNames(location, oneBrokerName, queueNamePattern)); // RECURSION
                }
            } else {
                String[] names = this.jmxActiveMQUtil.queryQueueNames(location, brokerName, queueNamePattern);
                result.addAll(Arrays.asList(names));
            }
        }

        return  result;
    }
protected Set < String > queryQueueNames ( String location , String brokerName , String queueNamePattern ) throws Exception { Set < String > result = new TreeSet < > ( ) ; if ( location . equals ( "*" ) ) { for ( String oneLocation : this . brokerRegistry . keys ( ) ) { result . addAll ( this . queryQueueNames ( oneLocation , brokerName , queueNamePattern ) ) ; } } else { if ( brokerName . equals ( "*" ) ) { String [ ] brokerNames = this . queryBrokerNames ( location ) ; for ( String oneBrokerName : brokerNames ) { result . addAll ( this . queryQueueNames ( location , oneBrokerName , queueNamePattern ) ) ; } } else { String [ ] names = this . jmxActiveMQUtil . queryQueueNames ( location , brokerName , queueNamePattern ) ; result . addAll ( Arrays . asList ( names ) ) ; } } return result ; }
TBD: don't create mutliple JMX connections when performing multiple queries (JMX connector pool?)