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-retry
和 spring-boot-starter-aop
,把如下代码添加到项目的 pom.xml 文件中
<dependency>
<groupId>org.springframework.retrygroupId>
<artifactId>spring-retryartifactId>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-aopartifactId>
dependency>
然后在 bootstrap.yml 文件中添加如下配置:
cloud:
config:
fail-fast: true
retry:
initial-interval: 1000
max-attempts: 15
max-interval: 2000
multiplier: 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://[email protected]: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/