spring-cloud / spring-cloud-consul

Spring Cloud Consul
http://cloud.spring.io/spring-cloud-consul/
Apache License 2.0
812 stars 541 forks source link

Fixes #416 The problem of multiple keys in ConfigWatch #705

Open takeseem opened 3 years ago

takeseem commented 3 years ago

for multiple configurations, generally the first one is the main configuration. so only the first configuration needs to be watch, the other will wait 1 second. (if waitTime=0, will wait 5 minutes)

contextIndex is order itself. It's init in ConsulPropertySourceLocator.locate(Environment environment)

for (String propertySourceContext : this.contexts) {
    ConsulPropertySource propertySource = sources.createPropertySource(propertySourceContext, true,
            this.consul, contextIndex::put);
    if (propertySource != null) {
        composite.addPropertySource(propertySource);
    }
}