diff --git a/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConfigWatch.java b/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConfigWatch.java index f2eea9f6..4b7b27e8 100644 --- a/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConfigWatch.java +++ b/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConfigWatch.java @@ -40,13 +40,16 @@ import lombok.extern.apachecommons.CommonsLog; */ @CommonsLog public class ConfigWatch implements Closeable, ApplicationEventPublisherAware { + + private final ConsulConfigProperties properties; private final List contexts; private final ConsulClient consul; private AtomicBoolean running = new AtomicBoolean(false); private ApplicationEventPublisher publisher; private HashMap consulIndexes = new HashMap<>(); - public ConfigWatch(List contexts, ConsulClient consul) { + public ConfigWatch(ConsulConfigProperties properties, List contexts, ConsulClient consul) { + this.properties = properties; this.contexts = contexts; this.consul = consul; } @@ -61,7 +64,7 @@ public class ConfigWatch implements Closeable, ApplicationEventPublisherAware { this.running.compareAndSet(false, true); } - @Scheduled(fixedDelayString = "${spring.cloud.consul.config.watch.delay:10}") + @Scheduled(fixedDelayString = "${spring.cloud.consul.config.watch.delay:100}") public void watchConfigKeyValues() { if (this.running.get()) { for (String context : this.contexts) { @@ -89,7 +92,11 @@ public class ConfigWatch implements Closeable, ApplicationEventPublisherAware { } } catch (Exception e) { - log.error("Error initializing listener for context " + context, e); + if (this.properties.isFailFast()) { + log.error("Error initializing listener for context " + context, e); + } else if (log.isTraceEnabled()) { + log.trace("Failfast is true. Error initializing listener for context " + context, e); + } } } } diff --git a/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulConfigAutoConfiguration.java b/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulConfigAutoConfiguration.java index 10759337..90b9f87f 100644 --- a/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulConfigAutoConfiguration.java +++ b/spring-cloud-consul-config/src/main/java/org/springframework/cloud/consul/config/ConsulConfigAutoConfiguration.java @@ -35,9 +35,9 @@ public class ConsulConfigAutoConfiguration { protected static class ConsulRefreshConfiguration { @Bean @ConditionalOnProperty(name = "spring.cloud.consul.config.watch.enabled", matchIfMissing = true) - public ConfigWatch configWatch(ConsulPropertySourceLocator locator, - ConsulClient consul) { - return new ConfigWatch(locator.getContexts(), consul); + public ConfigWatch configWatch(ConsulConfigProperties properties, + ConsulPropertySourceLocator locator, ConsulClient consul) { + return new ConfigWatch(properties, locator.getContexts(), consul); } } }