最近在使用Spring Cloud搭建配置中心的实例以及简易应用的时候,遇到了一个非常奇怪的问题。
项目结构
使用java -jar的方式启动了eureka注册中心集群(3台部署),一台zuul负责转发请求到服务,service-hi服务集群(2台部署),配置中心由一台server服务器和两台client构建而成。
需求
调用zuul,负载均衡到service-hi服务器,在service-hi服务器中通过feign的方式调用配置中心client中的key为foo的配置,并返回浏览器输出foo的值。之后,在git仓库修改foo的值,通过消息总线(RabbitMQ)更新配置文件,再次访问,查看配置内容是否成功更新。
出现的问题
在用消息总线refresh之前,调用正常,浏览器能成功返回foo的值。注册中心实例包括zuul*1,service-hi*2,server-config*1,client-config*2。
在用消息总线refresh之后,注册中心丢失client-config*2的实例,是丢失,不是down的状态。导致service-hi调用client-config时报错。单独通过client-config访问更新的配置信息,显示更新成功后的内容。
用消息总线refresh之前相关信息的截图:
注册中心集群中已经注册的实例:
service-hi中通过feign调用client-config
刷新消息总线前,访问zuul,成功获取到配置文件的值
使用消息总线更新配置之后的一些信息截图:
更新git仓库属性的值
使用post请求更新配置后client端产生的日志(日志中RejectedExecutionException异常,官方工程师声明该异常的确存在,但不影响程序运行):
2018-07-19 15:00:58.030 INFO 11780 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@5f683daf: startup date [Thu Jul 19 15:00:58 CST 2018]; root of context hierarchy
2018-07-19 15:00:58.970 INFO 11780 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-07-19 15:00:59.033 INFO 11780 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$fcf3eb8e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-19 15:01:00.004 INFO 11780 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2018-07-19 15:01:00.239 INFO 11780 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2018-07-19 15:01:01.186 INFO 11780 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2018-07-19 15:01:01.186 INFO 11780 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2018-07-19 15:01:01.392 INFO 11780 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2018-07-19 15:01:01.392 INFO 11780 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2018-07-19 15:01:01.795 INFO 11780 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2018-07-19 15:01:02.060 INFO 11780 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2018-07-19 15:01:02.060 INFO 11780 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2018-07-19 15:01:02.060 INFO 11780 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2018-07-19 15:01:02.061 INFO 11780 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false
2018-07-19 15:01:02.061 INFO 11780 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2018-07-19 15:01:02.061 INFO 11780 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2018-07-19 15:01:02.061 INFO 11780 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2018-07-19 15:01:02.409 INFO 11780 --- [ main] com.netflix.discovery.DiscoveryClient : The response status is 200
2018-07-19 15:01:02.413 INFO 11780 --- [ main] com.netflix.discovery.DiscoveryClient : Not registering with Eureka server per configuration
2018-07-19 15:01:02.420 INFO 11780 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1531983662420 with initial instances count: 5
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.6.RELEASE)
2018-07-19 15:01:03.255 INFO 11780 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://10.131.23.184:8770/
2018-07-19 15:01:14.937 INFO 11780 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=client-config, profiles=[test], label=master, version=d751349016e7d7a17ac9b14a570234cadb0ef399, state=null
2018-07-19 15:01:14.939 INFO 11780 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource [name='configService', propertySources=[MapPropertySource [name='configClient'], MapPropertySource [name='https://github.com/Vincent6311/test/client-config-test.properties'], MapPropertySource [name='https://github.com/Vincent6311/test/application-test.properties']]]
2018-07-19 15:01:14.946 INFO 11780 --- [ main] com.forezp.DigitalClientConfigApp : No active profile set, falling back to default profiles: default
2018-07-19 15:01:15.011 INFO 11780 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5ea4300e: startup date [Thu Jul 19 15:01:15 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@5f683daf
2018-07-19 15:01:16.461 INFO 11780 --- [ main] o.s.i.config.IntegrationRegistrar : No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created.
2018-07-19 15:01:17.426 INFO 11780 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=82e7a661-e702-3221-928d-061e89957668
2018-07-19 15:01:17.448 INFO 11780 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
2018-07-19 15:01:17.454 INFO 11780 --- [ main] faultConfiguringBeanFactoryPostProcessor : No bean named 'taskScheduler' has been explicitly defined. Therefore, a default ThreadPoolTaskScheduler will be created.
2018-07-19 15:01:17.474 INFO 11780 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-07-19 15:01:17.557 INFO 11780 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.amqp.rabbit.annotation.RabbitBootstrapConfiguration' of type [org.springframework.amqp.rabbit.annotation.RabbitBootstrapConfiguration$$EnhancerBySpringCGLIB$$a745a6bf] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-19 15:01:17.839 INFO 11780 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.netflix.metrics.MetricsInterceptorConfiguration$MetricsRestTemplateConfiguration' of type [org.springframework.cloud.netflix.metrics.MetricsInterceptorConfiguration$MetricsRestTemplateConfiguration$$EnhancerBySpringCGLIB$$13068ed2] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-19 15:01:18.046 INFO 11780 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'integrationGlobalProperties' of type [org.springframework.beans.factory.config.PropertiesFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-19 15:01:18.053 INFO 11780 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'integrationGlobalProperties' of type [java.util.Properties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-19 15:01:18.109 INFO 11780 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$fcf3eb8e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-19 15:01:18.123 INFO 11780 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.stream.config.BindingServiceConfiguration$PostProcessorConfiguration' of type [org.springframework.cloud.stream.config.BindingServiceConfiguration$PostProcessorConfiguration$$EnhancerBySpringCGLIB$$a2a18696] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-19 15:01:18.853 INFO 11780 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8771 (http)
2018-07-19 15:01:18.879 INFO 11780 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-07-19 15:01:18.882 INFO 11780 --- [ main] org.apache.catalina.core.StandardEngine