spring-cloud / spring-cloud-netflix

Integration with Netflix OSS components
http://cloud.spring.io/spring-cloud-netflix/
Apache License 2.0
4.88k stars 2.44k forks source link

eureka client down after invoke refreshScope.refreshAll() ? #4160

Open yonyong opened 1 year ago

yonyong commented 1 year ago

The service of the eureka client is offline after using refreshAll or refresh(beanName). My troubleshooting conclusion is that executing the refreshAll() or refresh(beanName)method will trigger multiple StatusChangeEvents and call the instance. setStatus() method in parallel to modify the instance status. My idea is to disable eureka refresh, but after turning off the configuration, the application can still receive the RefreshScopeRefreshedEvent event. So are there two things to consider? 1)If I set the configuration refresh to false: eureka.client.refresh.enable=false,then EurekaClientConfigurationRefresher should not receive the RefreshScopeRefreshedEvent event 2)If EurekaClientConfigurationRefresher receives the RefreshScopeRefreshedEvent event, it should do a layer of filtering, such as whether the event name is Eureka

spencergibb commented 1 year ago

Are you trying to disable refresh of a running application?

yonyong commented 1 year ago

Are you trying to disable refresh of a running application? ^_^ That's not it.

We use Apollo as our configuration hub and hot updates to our configuration are done using springcloud's refreshScope.refreshAll(). But the refreshAll method will rebuild the eureka bean and re-register to eureka server, which is not what we want, we just want to refresh a business configuration item. So I tried to configure eureka.client.refresh.enabled=false and restarted the project. But I found that org.springframework.cloud.netflix.eureka.EurekaDiscoveryClientConfiguration.EurekaClientConfigurationRefresher The onApplicationEvent method still receives the RefreshScopeRefreshedEvent event fired by refreshAll and performs an eureka reregistration. I don't think the design is quite right, is it?

yonyong commented 1 year ago

image I think when configure eureka.client.refresh.enable=false,this listener should be turned off as well. Otherwise a single call to refreshAll will trigger a re-registration of eureka here

chenguanglee commented 9 months ago

I also encountered such a problem

yonyong commented 9 months ago

I think this should be a problem with the eureka implementation. Just turn off the eureka refresh listener, see my fix package for details: https://github.com/yonyong/spring-cloud-netflix-eureka-patch.