protected String prepareBrokerPoller ( String brokerName , String address ) throws Exception { MBeanAccessConnectionFactory mBeanAccessConnectionFactory = this . jmxActiveMQUtil . getLocationConnectionFactory ( address ) ; if ( brokerName . equals ( "*" ) ) { String [ ] brokersAtLocation = this . jmxActiveMQUtil . queryBrokerNames ( address ) ; if ( brokersAtLocation == null ) { throw new Exception ( "unable to locate broker at " + address ) ; } else if ( brokersAtLocation . length != 1 ) { throw new Exception ( "found more than one broker at " + address + "; count=" + brokersAtLocation . length ) ; } else { brokerName = brokersAtLocation [ 0 ] ; } } this . brokerRegistry . put ( address , new BrokerInfo ( "unknown-broker-id" , brokerName , "unknown-broker-url" ) ) ; ActiveMQBrokerPoller brokerPoller = this . brokerPollerFactory . createPoller ( brokerName , mBeanAccessConnectionFactory , this . websocketBrokerStatsFeed ) ; brokerPoller . setQueueRegistry ( this . queueRegistry ) ; brokerPoller . setTopicRegistry ( this . topicRegistry ) ; // TBD: one automic update for brokerPollerMap and locations (is there an echo in here?) synchronized ( this . brokerPollerMap ) { if ( ! this . brokerPollerMap . containsKey ( address ) ) { this . brokerPollerMap . put ( address , brokerPoller ) ; } else { log . info ( "ignoring duplicate add of broker address {}" , address ) ; return "already exists" ; } } // No need to synchronize to avoid races here; the poller will not start if either already started, or already // stopped. if ( this . started . get ( ) ) { brokerPoller . start ( ) ; } // Add auto-discovery of Queues for this broker, if enabled if ( this . autoDiscoverQueues ) { this . prepareBrokerQueueDiscoverer ( brokerName , address , mBeanAccessConnectionFactory ) ; } return address + " = " + brokerName ; }
Prepare polling for the named broker at the given polling address .