@Bean(destroyMethod = "close") @ConditionalOnMissingBean @SneakyThrows public CuratorFramework curatorFramework( RetryPolicy retryPolicy, ZookeeperDiscoveryProperties properties) { CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder(); if (ensembleProvider != null) { builder.ensembleProvider(ensembleProvider); } CuratorFramework curator = builder .retryPolicy(retryPolicy) .connectString(zookeeperProperties.getConnectString()) .build(); curator.start(); log.trace( "blocking until connected to zookeeper for " + properties.getBlockUntilConnectedWait() + properties.getBlockUntilConnectedUnit()); curator.blockUntilConnected( properties.getBlockUntilConnectedWait(), properties.getBlockUntilConnectedUnit()); log.trace("connected to zookeeper"); return curator; }