spring-cloud-consul icon indicating copy to clipboard operation
spring-cloud-consul copied to clipboard

The problem of multiple keys in ConfigWatch

Open ChaoyongLiang opened this issue 6 years ago • 6 comments

Hi, I'm using consul config in a spring application, but I found a problem in the ConfigWatch. I have two keys to watch. One is config/application/data which is for the common configuration, the ohter is config/appName/data which is for the private configuraion. I hope that one of them is updated in consul, I need to kown the notification from consul. However, If config/application/data is blocked in the ConfigWatch and config/appName/data is updated now, the Spring application can't get any notification from consul. Because config keys are not blocked in the same time, they do watch action one by one. Therefore one key is blocked in watch, the other will not get any notification even if it has been updated.

for (String context : this.consulIndexes.keySet()) {
...
    Response<List<GetValue>> response = this.consul.getKVValues(context, aclToken,
        new QueryParams(this.properties.getWatch().getWaitTime(),
            currentIndex));
...
}

So, how can I do to solve this problem?

Thanks.

ChaoyongLiang avatar Apr 27 '18 07:04 ChaoyongLiang

They are executed in order. Are you saying that if one is updated while watching the other that the other is never updated?

spencergibb avatar Nov 19 '18 19:11 spencergibb

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues avatar Nov 26 '18 19:11 spring-projects-issues

They are executed in order. Are you saying that if one is updated while watching the other that the other is never updated?

Hello, thank you for your answer.

The othe is not never updated, it will update after the watching key has updated or watch timeout. eg: If config/application/data is blocked for 5 minutes in the ConfigWatch, the other key config/appName/data is updated now. However, I can't get notifycation from consul. Because ConfigWatch is watching the key config/application/data in process.

After 5 minutes, the watching config/application/data is returned, ConfigWatch starts to watch the other key config/appName/data, I can get notifycation from consul because the key has been updated. But the notifycation is delayed in 5 minutes.

I means that ConfigWatch should watch all keys that belong to the application concurrently, instead of one by one.

ChaoyongLiang avatar Nov 28 '18 09:11 ChaoyongLiang

I think the answer would be to execute them in parallel using projectreactor.io.

spencergibb avatar Dec 13 '18 18:12 spencergibb

Also looking for the same fix, concurrently watching each key seems to make most sense👍

SamG1000 avatar Oct 13 '20 20:10 SamG1000

It really needs improvement, the waiting time is too long in multiple configurations.

The first configuration is the main configuration, and I only need to monitor the first configuration.

details pull #705

takeseem avatar Feb 10 '21 02:02 takeseem