文章目录

  • Spring Cloud Config Client 失败快速响应与重试
  • 测试
  • 参考
  • 源代码

Spring Cloud Config Client 失败快速响应与重试

Spring Cloud Config的客户端会先加载自己的配置文件,然后再开始连接ConfigServer进行配置加载。 当我们构建的应用较为复杂的时候, 可能在连接ConfigServer之前花费较长的启动时间, 而在一些特殊场景下, 我们又希望可以快速知道当前应用是否能顺利地从ConfigServer获取到配置信息, 这对在初期构建调试环境时, 可以减少很多等待启动的时间。当然

当然上面是其中的一些原因,至于为什么我需要配置一下config client的失败快速响应和重试呢,是因为后面我会讲一下通过Docker Compose编排微服务,但是Docker Compose是很难控制容器的就绪的顺序,注意我这里说的是就绪的顺序,也就是等待一个容器启动完毕之后才启动另一个容器。这种是比较难控制的。所以当我们的config server端还没有就绪的时候,可能config client端已经在启动了,所以我们希望config client端能够快速的知道config server现在是否已经就绪了,而且不希望我们的config client端获取配置的时候失败,希望能够在失败之后能够重新尝试获取配置,以给 config server 时间进行恢复。基于以上的原因所以这里我需要来学习一下Spring Cloud Config Client失败快速响应与超时重试,当然关于Docker Compose编排微服务后面会讲到。

开启客户端重试功能需要两个新依赖,spring-retryspring-boot-starter-aop,把如下代码添加到项目的 pom.xml 文件中

<dependency><groupId>org.springframework.retry</groupId><artifactId>spring-retry</artifactId>
</dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-aop</artifactId>
</dependency>

然后在 bootstrap.yml 文件中添加如下配置:

cloud:config:fail-fast: trueretry:initial-interval: 1000max-attempts: 15max-interval: 2000multiplier: 1.1

首先把spring.cloud.config.fail-fast设置为true,即在获取不到远程配置时,立即失败,但是用下边的配置进行重试。

  • spring.cloud.config.retry 所有子项均为默认值:
  • initial-interval: 最初重试间隔为 1000 毫秒
  • max-attempts: 最多重试 15 次
  • max-interval: 最长重试间隔为 2000 毫秒
  • multiplier: 每次重试失败后,重试间隔所增加的倍数

测试

我们先把eureka启动起来,然后再把config server启动起来,之后我们关闭config server。之后我们启动我们的config client端的服务。 过一会之后我们在启动config server。

然后我们就可以看到我们config client端的日志如下:

2019-10-22 22:01:56.608  INFO [cloud-service-member,,,] 9604 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.retry.annotation.RetryConfiguration' of type [org.springframework.retry.annotation.RetryConfiguration$$EnhancerBySpringCGLIB$$a5c64fc6] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-10-22 22:01:56.634  INFO [cloud-service-member,,,] 9604 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$cc1cba9e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-10-22 22:02:06.201  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2019-10-22 22:02:06.224  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.c.n.eureka.InstanceInfoFactory       : Setting initial instance status as: STARTING
2019-10-22 22:02:06.319  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Initializing Eureka in region us-east-1
2019-10-22 22:02:06.493  INFO [cloud-service-member,,,] 9604 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2019-10-22 22:02:06.493  INFO [cloud-service-member,,,] 9604 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2019-10-22 22:02:06.719  INFO [cloud-service-member,,,] 9604 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2019-10-22 22:02:06.720  INFO [cloud-service-member,,,] 9604 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2019-10-22 22:02:06.999  INFO [cloud-service-member,,,] 9604 --- [           main] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2019-10-22 22:02:14.097  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Disable delta property : false
2019-10-22 22:02:14.098  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Single vip registry refresh property : null
2019-10-22 22:02:14.098  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Force full registry fetch : false
2019-10-22 22:02:14.098  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Application is null : false
2019-10-22 22:02:14.098  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Registered Applications size is zero : true
2019-10-22 22:02:14.098  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Application version is -1: true
2019-10-22 22:02:14.098  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Getting all instance registry info from the eureka server
2019-10-22 22:02:14.314  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : The response status is 200
2019-10-22 22:02:14.318  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Not registering with Eureka server per configuration
2019-10-22 22:02:14.324  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1571752934323 with initial instances count: 1.   ____          _            __ _ _/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/  ___)| |_)| | | | | || (_| |  ) ) ) )'  |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot ::        (v2.1.1.RELEASE)2019-10-22 22:02:22.853  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8090/
2019-10-22 22:02:24.914  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8090/. Will be trying the next url if available
2019-10-22 22:02:25.920  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8090/
2019-10-22 22:02:27.926  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8090/. Will be trying the next url if available
2019-10-22 22:02:29.030  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8090/
2019-10-22 22:02:31.036  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8090/. Will be trying the next url if available
2019-10-22 22:02:32.251  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8090/
2019-10-22 22:02:34.258  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8090/. Will be trying the next url if available
2019-10-22 22:02:35.592  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8090/
2019-10-22 22:02:37.605  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8090/. Will be trying the next url if available
2019-10-22 22:02:39.075  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8090/
2019-10-22 22:02:41.082  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8090/. Will be trying the next url if available
2019-10-22 22:02:42.697  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8090/
2019-10-22 22:02:44.703  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8090/. Will be trying the next url if available
2019-10-22 22:02:46.479  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8090/
2019-10-22 22:02:48.487  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8090/. Will be trying the next url if available
2019-10-22 22:02:50.438  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8090/
2019-10-22 22:02:52.445  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8090/. Will be trying the next url if available
2019-10-22 22:02:54.448  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8090/
2019-10-22 22:02:56.455  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8090/. Will be trying the next url if available
2019-10-22 22:02:58.459  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8090/
2019-10-22 22:03:00.473  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8090/. Will be trying the next url if available
2019-10-22 22:03:02.477  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8090/
2019-10-22 22:03:04.491  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8090/. Will be trying the next url if available
2019-10-22 22:03:06.495  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8090/
2019-10-22 22:03:20.426  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=cloud-service-member, profiles=[dev], label=null, version=0863d167ac2543a45a84fb01bed0716985539aca, state=null
2019-10-22 22:03:20.426  INFO [cloud-service-member,,,] 9604 --- [           main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='configClient'}, MapPropertySource {name='https://gitee.com/cckevincyh/spring-cloud-demo.git/cloud-config/dev/cloud-service-member/application.yml'}, MapPropertySource {name='https://gitee.com/cckevincyh/spring-cloud-demo.git/cloud-config/dev/common/application.yml'}, MapPropertySource {name='https://gitee.com/cckevincyh/spring-cloud-demo.git/cloud-config/default/common/application.yml'}]}
2019-10-22 22:03:20.472  INFO [cloud-service-member,,,] 9604 --- [           main] com.cc.cloud.member.MemberApp            : No active profile set, falling back to default profiles: default
2019-10-22 22:03:21.511  WARN [cloud-service-member,,,] 9604 --- [           main] o.s.boot.actuate.endpoint.EndpointId     : Endpoint ID 'bus-env' contains invalid characters, please migrate to a valid format.
2019-10-22 22:03:21.515  WARN [cloud-service-member,,,] 9604 --- [           main] o.s.boot.actuate.endpoint.EndpointId     : Endpoint ID 'bus-refresh' contains invalid characters, please migrate to a valid format.
2019-10-22 22:03:21.867  WARN [cloud-service-member,,,] 9604 --- [           main] o.s.boot.actuate.endpoint.EndpointId     : Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
2019-10-22 22:03:21.962  WARN [cloud-service-member,,,] 9604 --- [           main] o.s.boot.actuate.endpoint.EndpointId     : Endpoint ID 'hystrix.stream' contains invalid characters, please migrate to a valid format.
2019-10-22 22:03:22.262  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=00d31ea1-f947-3eaf-9d39-547d762fe562
2019-10-22 22:03:22.284  INFO [cloud-service-member,,,] 9604 --- [           main] faultConfiguringBeanFactoryPostProcessor : No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
2019-10-22 22:03:22.296  INFO [cloud-service-member,,,] 9604 --- [           main] faultConfiguringBeanFactoryPostProcessor : No bean named 'taskScheduler' has been explicitly defined. Therefore, a default ThreadPoolTaskScheduler will be created.
2019-10-22 22:03:22.304  INFO [cloud-service-member,,,] 9604 --- [           main] faultConfiguringBeanFactoryPostProcessor : No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created.
2019-10-22 22:03:22.331  INFO [cloud-service-member,,,] 9604 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.amqp.rabbit.annotation.RabbitBootstrapConfiguration' of type [org.springframework.amqp.rabbit.annotation.RabbitBootstrapConfiguration$$EnhancerBySpringCGLIB$$766e75cf] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-10-22 22:03:22.639  INFO [cloud-service-member,,,] 9604 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'integrationDisposableAutoCreatedBeans' of type [org.springframework.integration.config.annotation.Disposables] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-10-22 22:03:22.693  INFO [cloud-service-member,,,] 9604 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.integration.config.IntegrationManagementConfiguration' of type [org.springframework.integration.config.IntegrationManagementConfiguration$$EnhancerBySpringCGLIB$$1af472d0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-10-22 22:03:22.715  INFO [cloud-service-member,,,] 9604 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration$IntegrationJmxConfiguration' of type [org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration$IntegrationJmxConfiguration$$EnhancerBySpringCGLIB$$f6867df0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-10-22 22:03:22.733  INFO [cloud-service-member,,,] 9604 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration' of type [org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration$$EnhancerBySpringCGLIB$$2f6e26bd] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-10-22 22:03:22.753  INFO [cloud-service-member,,,] 9604 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'mbeanServer' of type [com.sun.jmx.mbeanserver.JmxMBeanServer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-10-22 22:03:22.801  INFO [cloud-service-member,,,] 9604 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$cc1cba9e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-10-22 22:03:23.411  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8762 (http)
2019-10-22 22:03:23.439  INFO [cloud-service-member,,,] 9604 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-10-22 22:03:23.439  INFO [cloud-service-member,,,] 9604 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/9.0.13
2019-10-22 22:03:23.446  INFO [cloud-service-member,,,] 9604 --- [           main] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_92\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Java\jdk1.8.0_92\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;D:\Maven\apache-maven-3.2.5\bin;D:\Groovy-2.4.7\bin;C:\Windows\System32;D:\Git\cmd;D:\GitExtensions\;C:\NodeJS\;D:\Docker Toolbox;C:\WINDOWS;C:\WINDOWS\system32\wbem;C:\WINDOWS\system32;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\minikube;D:\kubectl;C:\Users\c\AppData\Local\Programs\Python\Python36\Scripts\;C:\Users\c\AppData\Local\Programs\Python\Python36\;C:\Users\c\AppData\Roaming\npm;C:\Users\c\AppData\Local\Microsoft\WindowsApps;;D:\Docker Toolbox;.]
2019-10-22 22:03:23.647  INFO [cloud-service-member,,,] 9604 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-10-22 22:03:23.647  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3157 ms
2019-10-22 22:03:23.864  WARN [cloud-service-member,,,] 9604 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2019-10-22 22:03:23.864  INFO [cloud-service-member,,,] 9604 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-10-22 22:03:23.879  INFO [cloud-service-member,,,] 9604 --- [           main] c.netflix.config.DynamicPropertyFactory  : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@a1e912f
2019-10-22 22:03:29.780  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'taskScheduler'
2019-10-22 22:03:30.300  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.b.a.e.web.ServletEndpointRegistrar   : Registered '/actuator/hystrix.stream' to hystrix.stream-actuator-endpoint
2019-10-22 22:03:30.377  WARN [cloud-service-member,,,] 9604 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2019-10-22 22:03:30.377  INFO [cloud-service-member,,,] 9604 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2019-10-22 22:03:30.711  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-10-22 22:03:39.115  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2019-10-22 22:03:46.452  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
2019-10-22 22:03:52.987  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Shutting down DiscoveryClient ...
2019-10-22 22:03:52.995  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Completed shut down of DiscoveryClient
2019-10-22 22:03:53.182  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 25 endpoint(s) beneath base path '/actuator'
2019-10-22 22:03:53.361  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.c.s.m.DirectWithAttributesChannel    : Channel 'cloud-service-member-1.springCloudBusInput' has 1 subscriber(s).
2019-10-22 22:03:53.535  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageChannel errorChannel
2019-10-22 22:03:53.629  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageChannel springCloudBusOutput
2019-10-22 22:03:53.680  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageChannel springCloudBusInput
2019-10-22 22:03:53.688  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageChannel nullChannel
2019-10-22 22:03:53.714  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageHandler errorLogger
2019-10-22 22:03:53.737  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageHandler org.springframework.cloud.stream.binding.StreamListenerMessageHandler@7fd4b9ec
2019-10-22 22:03:53.781  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.i.endpoint.EventDrivenConsumer       : Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel
2019-10-22 22:03:53.782  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.i.channel.PublishSubscribeChannel    : Channel 'cloud-service-member-1.errorChannel' has 1 subscriber(s).
2019-10-22 22:03:53.782  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.i.endpoint.EventDrivenConsumer       : started _org.springframework.integration.errorLogger
2019-10-22 22:04:01.254  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://192.168.174.1:8090/
2019-10-22 22:04:09.478  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=cloud-service-member, profiles=[dev], label=null, version=0863d167ac2543a45a84fb01bed0716985539aca, state=null
2019-10-22 22:04:09.478  INFO [cloud-service-member,,,] 9604 --- [           main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='configClient'}, MapPropertySource {name='https://gitee.com/cckevincyh/spring-cloud-demo.git/cloud-config/dev/cloud-service-member/application.yml'}, MapPropertySource {name='https://gitee.com/cckevincyh/spring-cloud-demo.git/cloud-config/dev/common/application.yml'}, MapPropertySource {name='https://gitee.com/cckevincyh/spring-cloud-demo.git/cloud-config/default/common/application.yml'}]}
2019-10-22 22:04:09.993  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.a.r.c.CachingConnectionFactory       : Attempting to connect to: [192.168.99.100:5672]
2019-10-22 22:04:10.040  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.a.r.c.CachingConnectionFactory       : Created new connection: rabbitConnectionFactory#65f5cae3:0/SimpleConnection@1b53e6fc [delegate=amqp://guest@192.168.99.100:5672/, localPort= 55618]
2019-10-22 22:04:10.090  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.c.s.m.DirectWithAttributesChannel    : Channel 'cloud-service-member-1.springCloudBusOutput' has 1 subscriber(s).
2019-10-22 22:04:10.108  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.c.n.eureka.InstanceInfoFactory       : Setting initial instance status as: STARTING
2019-10-22 22:04:10.117  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Initializing Eureka in region us-east-1
2019-10-22 22:04:10.121  INFO [cloud-service-member,,,] 9604 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2019-10-22 22:04:10.121  INFO [cloud-service-member,,,] 9604 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2019-10-22 22:04:10.121  INFO [cloud-service-member,,,] 9604 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2019-10-22 22:04:10.121  INFO [cloud-service-member,,,] 9604 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2019-10-22 22:04:10.189  INFO [cloud-service-member,,,] 9604 --- [           main] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2019-10-22 22:04:10.479  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Disable delta property : false
2019-10-22 22:04:10.480  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Single vip registry refresh property : null
2019-10-22 22:04:10.480  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Force full registry fetch : false
2019-10-22 22:04:10.480  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Application is null : false
2019-10-22 22:04:10.480  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Registered Applications size is zero : true
2019-10-22 22:04:10.480  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Application version is -1: true
2019-10-22 22:04:10.480  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Getting all instance registry info from the eureka server
2019-10-22 22:04:10.485  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : The response status is 200
2019-10-22 22:04:10.486  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Starting heartbeat executor: renew interval is: 30
2019-10-22 22:04:10.489  INFO [cloud-service-member,,,] 9604 --- [           main] c.n.discovery.InstanceInfoReplicator     : InstanceInfoReplicator onDemand update allowed rate per min is 4
2019-10-22 22:04:10.490  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1571753050490 with initial instances count: 1
2019-10-22 22:04:10.498  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.c.n.e.s.EurekaServiceRegistry        : Registering application CLOUD-SERVICE-MEMBER with eureka with status UP
2019-10-22 22:04:10.499  INFO [cloud-service-member,,,] 9604 --- [           main] com.netflix.discovery.DiscoveryClient    : Saw local status change event StatusChangeEvent [timestamp=1571753050499, current=UP, previous=STARTING]
2019-10-22 22:04:10.502  INFO [cloud-service-member,,,] 9604 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_CLOUD-SERVICE-MEMBER/localhost:cloud-service-member:8762: registering service...
2019-10-22 22:04:10.546  INFO [cloud-service-member,,,] 9604 --- [           main] c.s.b.r.p.RabbitExchangeQueueProvisioner : declaring queue for inbound: springCloudBus.anonymous.v2plp5JlS8mxp04vaNlUxw, bound to: springCloudBus
2019-10-22 22:04:10.548  INFO [cloud-service-member,,,] 9604 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_CLOUD-SERVICE-MEMBER/localhost:cloud-service-member:8762 - registration status: 204
2019-10-22 22:04:10.585  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.i.monitor.IntegrationMBeanExporter   : Registering MessageChannel springCloudBus.anonymous.v2plp5JlS8mxp04vaNlUxw.errors
2019-10-22 22:04:10.745  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.c.stream.binder.BinderErrorChannel   : Channel 'cloud-service-member-1.springCloudBus.anonymous.v2plp5JlS8mxp04vaNlUxw.errors' has 1 subscriber(s).
2019-10-22 22:04:10.746  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.c.stream.binder.BinderErrorChannel   : Channel 'cloud-service-member-1.springCloudBus.anonymous.v2plp5JlS8mxp04vaNlUxw.errors' has 2 subscriber(s).
2019-10-22 22:04:10.790  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.i.a.i.AmqpInboundChannelAdapter      : started inbound.springCloudBus.anonymous.v2plp5JlS8mxp04vaNlUxw
2019-10-22 22:04:11.046  INFO [cloud-service-member,,,] 9604 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8762 (http) with context path ''
2019-10-22 22:04:11.046  INFO [cloud-service-member,,,] 9604 --- [           main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8762

我们可以看到下面的log,看到config client端是尝试去连接config server,如果我们中途启动了config server,那么我们的config client端就能启动成功。

2019-10-22 22:02:27.926  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8090/. Will be trying the next url if available
2019-10-22 22:02:29.030  INFO [cloud-service-member,,,] 9604 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8090/

参考

Spring Cloud Config Client 超时与重试

spring-cloud-config失败快速响应与重试

Spring Cloud Config Client 超时与重试

源代码

https://gitee.com/cckevincyh/spring-cloud-demo/tree/config-client-retry/

【Spring Cloud 基础设施搭建系列】Spring Cloud Demo项目 Spring Cloud Config Client 失败快速响应与超时重试相关推荐

  1. 【Spring Cloud 基础设施搭建系列】Spring Cloud Demo项目 将微服务运行在Docker上

    文章目录 将微服务运行在Docker上 使用Maven插件构建Docker镜像 使用Maven插件读取Dockerfile进行构建 将插件绑定在某个phase执行 参考 源代码 将微服务运行在Dock ...

  2. 【Spring Cloud 基础设施搭建系列】Spring Cloud Demo项目 Spring Boot Test集成测试环境搭建

    文章目录 集成测试 @SpringBootTest的集成测试 Spring Boot Test集成测试环境搭建 参考 源代码 集成测试 集成测试(Integration Testing,缩写为INT) ...

  3. 【Spring Cloud 基础设施搭建系列】Spring Cloud Demo项目 使用Docker Compose编排Spring Cloud微服务

    文章目录 Docker Compose快速人门 入门示例 使用Docker Comose编排Spring Cloud微服务 使用Maven插件读取Dockerfile进行构建 使用Maven插件构建D ...

  4. spring源码解读系列(八):观察者模式--spring监听器详解

    一.前言 在前面的文章spring源码解读系列(七)中,我们继续剖析了spring的核心refresh()方法中的registerBeanPostProcessors(beanFactory)(完成B ...

  5. Spring Boot 3.x 系列【23】集成Spring WebFlux开发响应式应用程序

    有道无术,术尚可求,有术无道,止于术. 本系列Spring Boot版本3.0.4 源码地址:https://gitee.com/pearl-organization/study-spring-boo ...

  6. spring cloud 快速上手系列 -> 02-配置中心 Config -> 022-Config客户端

    spring cloud 快速上手系列 系列说明:快速上手,一切从简,搭建一个简单的微服务框架,让新手可以在这个基础框架上做各种学习.研究. 02-配置中心 Config 022-Config客户端 ...

  7. spring cloud 快速上手系列 -> 04-网关 Gateway -> 041-空的工程

    spring cloud 快速上手系列 系列说明:快速上手,一切从简,搭建一个简单的微服务框架,让新手可以在这个基础框架上做各种学习.研究. 04-网关 Gateway 041-空的工程 1,说明 网 ...

  8. Spring Cloud微服务系列文,服务调用框架Feign

    之前博文的案例中,我们是通过RestTemplate来调用服务,而Feign框架则在此基础上做了一层封装,比如,可以通过注解等方式来绑定参数,或者以声明的方式来指定请求返回类型是JSON.    这种 ...

  9. eureka集群只注册一个_Spring cloud系列教程第十篇- Spring cloud整合Eureka总结篇

    Spring cloud系列教程第十篇- Spring cloud整合Eureka总结篇 本文主要内容: 1:spring cloud整合Eureka总结 本文是由凯哥(凯哥Java:kagejava ...

最新文章

  1. 使用PyTorch时,最常见的4个错误
  2. Winform中连接Mysql8并查询表中数据进行显示
  3. Solaris9 Sparc下安装JDK6.0和tomcat6.0
  4. day 64 Django 第五天 多表对多表的对应关系ORM
  5. editorconfig常用配置
  6. 使用android-junit-report.jar导出单元测试报告
  7. Spring 的动态数据源实现
  8. xp 无法运行 php.exe,【xpexe文件不能执行】xp exe文件打不开_xp系统exe文件打不开-系统城...
  9. 二进制补码以及为什么要使用补码
  10. Sql server一些常见性能问题的总结
  11. 如何用java实现一个p2p种子搜索(4)-种子获取
  12. 15000字看完lululemon增长攻略
  13. 编译问题追踪 :高通驱动移植 <utils/Log.h>问题
  14. 云宏超融合+英特尔® =?
  15. 数字图像处理 --- 图像的傅里叶变换的频谱特征 二(方向性)
  16. “enumeration value ‘xxxxx‘ not handled in switch“警告
  17. 开关电源雷击浪涌整改_开关电源的抗浪涌雷击电路的制作方法
  18. 解决MySql数据库远程访问Access denied for user: xxx@%' to database ‘datatest’ 问题
  19. IE中调试javascript的方法
  20. Maven构建聚合工程以及jar包冲突解决使用总结

热门文章

  1. 线性拟合的 R2 和p值怎么计算
  2. 2018计算机同济考研初试复试经验分享
  3. vue3+vite+EChars LPL数据可视化项目总结
  4. 逆境发财致富的六条黄金法则
  5. excel 公式 单引号 concat_电气计算速度慢?62套自动计算EXCEL表格,输入数据秒出结果...
  6. 【数据结构与算法】思维导图
  7. 微软云虚拟机外网访问
  8. QT无法configure project,卡在项目界面
  9. 关于vs qt 64位程序 编译文件0xc000007b错误的解决方案
  10. 孙悟空无姓无名的时候,阎王生死簿是怎么写的呢?