public void pollOnce ( ) throws IOException { MBeanAccessConnection connection = this . mBeanAccessConnectionFactory . createConnection ( ) ; // // Set of Queues known at start in order to detect Queues lost. This set may contain queues already known to // have been lost. // Set < String > remainingQueues = new HashSet <> ( this . registry . keys ( ) ) ; try { ObjectName destinationPattern = this . jmxActiveMQUtil . getDestinationObjectName ( this . brokerName , "*" , this . destinationType ) ; Set < ObjectName > found = connection . queryNames ( destinationPattern , null ) ; // // Iterate over the mbean names matching the pattern, extract the destination name, and process. // for ( ObjectName oneDestOName : found ) { String destName = this . jmxActiveMQUtil . extractDestinationName ( oneDestOName ) ; this . onFoundDestination ( destName ) ; remainingQueues . remove ( destName ) ; } // // Mark any queues remaining in the expected queue set as not known by the broker. // for ( String missingQueue : remainingQueues ) { DestinationState destState = this . registry . get ( missingQueue ) ; if ( destState != null ) { // Remove now if not known by any broker. if ( ! destState . existsAnyBroker ( ) ) { this . registry . remove ( missingQueue ) ; } else { destState . putBrokerInfo ( this . brokerId , false ) ; } } } } catch ( MalformedObjectNameException monExc ) { throw new RuntimeException ( "unexpected object name failure for destinationType=" + this . destinationType , monExc ) ; } finally { this . safeClose ( connection ) ; } }
Poll for destinations and update the registry with new destinations found and clean out destinations not found and not existing on any broker .