private Transport buildTransport ( Map < String , String > params , final List < ServiceInformation > services ) throws IOException { final String configPostfix = getConfig ( params ) . getServiceConfigurationPostfix ( ) ; final StringBuilder uriBuilder = new StringBuilder ( ) ; uriBuilder . append ( "failover:(" ) ; uriBuilder . append ( Joiner . on ( ' ' ) . join ( Collections2 . transform ( services , SERVICE_TO_URI ) ) ) ; uriBuilder . append ( ' ' ) ; if ( ! StringUtils . isBlank ( configPostfix ) ) { uriBuilder . append ( ' ' ) ; uriBuilder . append ( configPostfix ) ; } try { final URI uri = URI . create ( uriBuilder . toString ( ) ) ; LOG . debug ( "Service discovery transport discovered %s" , uri ) ; return interceptPropertySetters ( TransportFactory . compositeConnect ( uri ) ) ; } catch ( final Exception e ) { Throwables . propagateIfPossible ( e , IOException . class ) ; throw new IOException ( "Could not create failover transport" , e ) ; } }
From a list of ServiceInformation build a failover transport that balances between the brokers .