Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Why do two callbacks happen? #423

Open
yancheng199287 opened this issue Aug 2, 2020 · 3 comments
Open

Why do two callbacks happen? #423

yancheng199287 opened this issue Aug 2, 2020 · 3 comments

Comments

@yancheng199287
Copy link

yancheng199287 commented Aug 2, 2020

     val svHealth = ServiceHealthCache.newCache(healthClient, serviceName, false, 10, QueryOptions.BLANK)
        svHealth.addListener { newValues: Map<ServiceHealthKey, ServiceHealth> ->
            run {
                println("----------------")
                logger.info(JSON.toJSONString(IMServerInstance.parserConsulClientServiceInstance(newValues)))
            }
        }
        svHealth.start()

my log show twice callback for same service id when I kill a server

as follows

----------------
21:41:14.435 [OkHttp http://localhost:8500/...] INFO com.oneinlet.ConsulClientService - {"dataCenter":"dc1","id":"c87870158a643ec79044af3997524ee5","metaData":{"serverInstancePublicIp":"localhost"},"name":"Interesting-IM-Service","nodeAddress":"127.0.0.1","nodeName":"DESKTOP-EOTSJE5","serverInstancePort":80,"serviceTagList":[],"status":"critical"}
21:41:15.431 [OkHttp http://localhost:8500/...] DEBUG com.orbitz.consul.cache.ConsulCache - Consul cache updated for health.service "Interesting-IM-Service" (index=339), request duration: 996 ms
----------------
21:41:15.432 [OkHttp http://localhost:8500/...] INFO com.oneinlet.ConsulClientService - {"dataCenter":"dc1","id":"c87870158a643ec79044af3997524ee5","metaData":{"serverInstancePublicIp":"localhost"},"name":"Interesting-IM-Service","nodeAddress":"127.0.0.1","nodeName":"DESKTOP-EOTSJE5","serverInstancePort":80,"serviceTagList":[],"status":"critical"}
2

@yancheng199287
Copy link
Author

update

@yancheng199287
Copy link
Author

I wrote it in kotlin,thanks

@lwsbox
Copy link

lwsbox commented Jan 7, 2021

maybe cased by your health indicator changed

for example:
{"status":"UP","diskSpace":{"status":"UP","total":117081018368,"free":26488745984,"threshold":10485760},
if the free indicator changed would run the callback.

Maybe should avoid this situation?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants