上一篇中讲到,如果需要客户端获取到最新的配置信息需要执行refresh,我们可以利用 Webhook 的机制每次提交代码发送请求来刷新客户端,当客户端越来越多的时候,需要每个客户端都执行一遍,这种方案就不太适合了。使用 Spring Cloud Bus 可以完美解决这一问题。

服务端

新建一个spring boot项目,命名 service-config-server-bus

POM 配置

 <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId>
8 </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>

配置文件

application.yml 内容如下

server:
port: 9300
spring:
application:
name: service-config-server-bus
cloud:
config:
server:
git:
uri: https://github.com/carry-chan/spring-cloud # 配置git仓库的地址
search-paths: config-repo # git仓库地址下的相对地址,可以配置多个,用,分割。
bus:
enabled: true
trace:
enabled: true
rabbitmq:
addresses: 192.168.68.100
port: 5672
username: test
password: 123456
eureka:
client:
serviceUrl:
defaultZone: http://admin:123456@localhost:8761/eureka/
management:
endpoints:
web:
exposure:
include: bus-refresh

启动类

 package com.carry.springcloud;

 import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer; @SpringBootApplication
@EnableConfigServer
public class ServiceConfigClientBusApplication { public static void main(String[] args) {
SpringApplication.run(ServiceConfigClientBusApplication.class, args);
}
}

客户端

新建spring boot项目 service-config-client-bus

POM 配置

 <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-bus</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>

配置文件

application.yml

server:
port: 9401
spring:
application:
name: service-config-client
cloud:
bus:
enabled: true
trace:
enabled: true
rabbitmq:
addresses: 192.168.68.100
port: 5672
username: test
password: 123456

bootstrap.yml

spring:
cloud:
config:
name: config-server # 对应 {application} 部分
profile: dev # 对应 {profile} 部分
label: master # 对应 {label} 部分,即 Git 的分支。如果配置中心使用的是本地存储,则该参数无用
discovery:
enabled: true
service-id: service-config-server-bus #springcloud config的服务名
eureka:
client:
serviceUrl:
defaultZone: http://admin:123456@localhost:8761/eureka/

控制层Controller

 package com.carry.springcloud;

 import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import reactor.core.publisher.Mono; @RestController
@RefreshScope
public class ClientController { @Value("${info.profile}")
private String profile; @GetMapping("/info")
public Mono<String> hello() {
return Mono.justOrEmpty(profile);
}
}

@RefreshScope必须加,否则客户端会受到服务端的更新消息,但是更新不了,因为不知道更新哪里的,至于启动主类,用默认生成的不用改。

测试

分别启动 eureka-server、service-config-server-bus 和两个 service-config-client-bus

启动后,RabbitMQ 中会自动创建一个 topic 类型的 Exchange 和两个以springCloudBus.anonymous.开头的匿名 Queue

我们用Postman发生请求 http://localhost:9400/info 和 http://localhost:9401/info 返回内容的都是dev

将 Git 中的配置信息由dev改为dev bus,并执行POST  http://localhost:9300/actuator/bus-refresh 之后,再请求 http://localhost:9400/info 和 http://localhost:9401/info ,返回dev bus 说明成功了。

服务端在刷新接口产生的的日志:

2018-08-31 16:50:43.182  INFO 18112 --- [nio-9300-exec-9] o.s.a.r.c.CachingConnectionFactory       : Attempting to connect to: [192.168.68.100:5672]
2018-08-31 16:50:43.211 INFO 18112 --- [nio-9300-exec-9] o.s.a.r.c.CachingConnectionFactory : Created new connection: rabbitConnectionFactory.publisher#1322bcdc:0/SimpleConnection@1799d006 [delegate=amqp://test@192.168.68.100:5672/, localPort= 52394]
2018-08-31 16:50:43.225 INFO 18112 --- [nio-9300-exec-9] o.s.amqp.rabbit.core.RabbitAdmin : Auto-declaring a non-durable, auto-delete, or exclusive Queue (springCloudBus.anonymous.91dZPs4ITESmKzjJHBhVoA) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.
2018-08-31 16:50:44.299 INFO 18112 --- [nio-9300-exec-9] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2018-08-31 16:50:44.374 INFO 18112 --- [nio-9300-exec-9] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@1c63e07d: startup date [Fri Aug 31 16:50:44 CST 2018]; root of context hierarchy
2018-08-31 16:50:44.399 INFO 18112 --- [nio-9300-exec-9] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-08-31 16:50:44.416 INFO 18112 --- [nio-9300-exec-9] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$a801f44] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-08-31 16:50:45.541 INFO 18112 --- [nio-9300-exec-9] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2018-08-31 16:50:45.565 INFO 18112 --- [nio-9300-exec-9] o.s.boot.SpringApplication : No active profile set, falling back to default profiles: default
2018-08-31 16:50:45.567 INFO 18112 --- [nio-9300-exec-9] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@1539f21d: startup date [Fri Aug 31 16:50:45 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@1c63e07d
2018-08-31 16:50:45.569 INFO 18112 --- [nio-9300-exec-9] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-08-31 16:50:45.578 INFO 18112 --- [nio-9300-exec-9] o.s.boot.SpringApplication : Started application in 2.337 seconds (JVM running for 2768.887)
2018-08-31 16:50:45.578 INFO 18112 --- [nio-9300-exec-9] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@1539f21d: startup date [Fri Aug 31 16:50:45 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@1c63e07d
2018-08-31 16:50:45.579 INFO 18112 --- [nio-9300-exec-9] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@1c63e07d: startup date [Fri Aug 31 16:50:44 CST 2018]; root of context hierarchy
2018-08-31 16:50:45.707 INFO 18112 --- [nio-9300-exec-9] com.netflix.discovery.DiscoveryClient : Shutting down DiscoveryClient ...
2018-08-31 16:50:45.709 INFO 18112 --- [nio-9300-exec-9] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2018-08-31 16:50:48.673 INFO 18112 --- [nio-9300-exec-9] com.netflix.discovery.DiscoveryClient : Unregistering ...
2018-08-31 16:50:48.693 INFO 18112 --- [nio-9300-exec-9] com.netflix.discovery.DiscoveryClient : DiscoveryClient_SERVICE-CONFIG-SERVER-BUS/localhost:service-config-server-bus:9300 - deregister status: 200
2018-08-31 16:50:48.727 INFO 18112 --- [nio-9300-exec-9] com.netflix.discovery.DiscoveryClient : Completed shut down of DiscoveryClient
2018-08-31 16:50:48.736 INFO 18112 --- [nio-9300-exec-9] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2018-08-31 16:50:48.741 INFO 18112 --- [nio-9300-exec-9] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2018-08-31 16:50:48.741 INFO 18112 --- [nio-9300-exec-9] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2018-08-31 16:50:48.741 INFO 18112 --- [nio-9300-exec-9] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2018-08-31 16:50:48.741 INFO 18112 --- [nio-9300-exec-9] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2018-08-31 16:50:48.865 INFO 18112 --- [nio-9300-exec-9] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2018-08-31 16:50:48.865 INFO 18112 --- [nio-9300-exec-9] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2018-08-31 16:50:48.865 INFO 18112 --- [nio-9300-exec-9] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2018-08-31 16:50:48.866 INFO 18112 --- [nio-9300-exec-9] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2018-08-31 16:50:48.866 INFO 18112 --- [nio-9300-exec-9] com.netflix.discovery.DiscoveryClient : Application is null : false
2018-08-31 16:50:48.866 INFO 18112 --- [nio-9300-exec-9] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2018-08-31 16:50:48.866 INFO 18112 --- [nio-9300-exec-9] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2018-08-31 16:50:48.866 INFO 18112 --- [nio-9300-exec-9] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2018-08-31 16:50:48.870 INFO 18112 --- [nio-9300-exec-9] com.netflix.discovery.DiscoveryClient : The response status is 200
2018-08-31 16:50:48.871 INFO 18112 --- [nio-9300-exec-9] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 30
2018-08-31 16:50:48.873 INFO 18112 --- [nio-9300-exec-9] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2018-08-31 16:50:48.874 INFO 18112 --- [nio-9300-exec-9] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1535705448874 with initial instances count: 3
2018-08-31 16:50:48.877 INFO 18112 --- [nio-9300-exec-9] o.s.c.n.e.s.EurekaServiceRegistry : Unregistering application service-config-server-bus with eureka with status DOWN
2018-08-31 16:50:48.877 INFO 18112 --- [nio-9300-exec-9] o.s.c.n.e.s.EurekaServiceRegistry : Registering application service-config-server-bus with eureka with status UP
2018-08-31 16:50:48.877 WARN 18112 --- [nio-9300-exec-9] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1535705448877, current=UP, previous=DOWN]
2018-08-31 16:50:48.878 INFO 18112 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_SERVICE-CONFIG-SERVER-BUS/localhost:service-config-server-bus:9300: registering service...
2018-08-31 16:50:48.880 INFO 18112 --- [nio-9300-exec-9] o.s.cloud.bus.event.RefreshListener : Received remote refresh request. Keys refreshed []
2018-08-31 16:50:48.886 INFO 18112 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_SERVICE-CONFIG-SERVER-BUS/localhost:service-config-server-bus:9300 - registration status: 204
2018-08-31 16:50:49.161 INFO 18112 --- [io-9300-exec-10] .c.s.e.MultipleJGitEnvironmentRepository : Fetched for remote master and found 1 updates
2018-08-31 16:50:50.235 INFO 18112 --- [io-9300-exec-10] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2018-08-31 16:50:50.291 INFO 18112 --- [io-9300-exec-10] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@2a199145: startup date [Fri Aug 31 16:50:50 CST 2018]; root of context hierarchy
2018-08-31 16:50:50.293 INFO 18112 --- [io-9300-exec-10] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-08-31 16:50:50.298 INFO 18112 --- [io-9300-exec-10] o.s.c.c.s.e.NativeEnvironmentRepository : Adding property source: file:/C:/Users/ADMINI~1/AppData/Local/Temp/config-repo-4017042254956212660/config-repo/config-server-dev.yml
2018-08-31 16:50:50.298 INFO 18112 --- [io-9300-exec-10] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@2a199145: startup date [Fri Aug 31 16:50:50 CST 2018]; root of context hierarchy
2018-08-31 16:50:52.554 INFO 18112 --- [nio-9300-exec-1] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2018-08-31 16:50:52.605 INFO 18112 --- [nio-9300-exec-1] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@2013736a: startup date [Fri Aug 31 16:50:52 CST 2018]; root of context hierarchy
2018-08-31 16:50:52.611 INFO 18112 --- [nio-9300-exec-1] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-08-31 16:50:52.616 INFO 18112 --- [nio-9300-exec-1] o.s.c.c.s.e.NativeEnvironmentRepository : Adding property source: file:/C:/Users/ADMINI~1/AppData/Local/Temp/config-repo-4017042254956212660/config-repo/config-server-dev.yml
2018-08-31 16:50:52.616 INFO 18112 --- [nio-9300-exec-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@2013736a: startup date [Fri Aug 31 16:50:52 CST 2018]; root of context hierarchy

客户端在刷新接口产生的的日志:

2018-08-31 16:50:28.853  INFO 9324 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2018-08-31 16:50:44.332 INFO 9324 --- [9uOLZV0TWJm8g-1] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2018-08-31 16:50:44.379 INFO 9324 --- [9uOLZV0TWJm8g-1] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@6f60de07: startup date [Fri Aug 31 16:50:44 CST 2018]; root of context hierarchy
2018-08-31 16:50:44.439 INFO 9324 --- [9uOLZV0TWJm8g-1] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-08-31 16:50:44.464 INFO 9324 --- [9uOLZV0TWJm8g-1] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$8ecaf823] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-08-31 16:50:45.555 INFO 9324 --- [9uOLZV0TWJm8g-1] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2018-08-31 16:50:45.572 INFO 9324 --- [9uOLZV0TWJm8g-1] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2018-08-31 16:50:45.584 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2018-08-31 16:50:45.590 INFO 9324 --- [9uOLZV0TWJm8g-1] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2018-08-31 16:50:45.590 INFO 9324 --- [9uOLZV0TWJm8g-1] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2018-08-31 16:50:45.590 INFO 9324 --- [9uOLZV0TWJm8g-1] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2018-08-31 16:50:45.590 INFO 9324 --- [9uOLZV0TWJm8g-1] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2018-08-31 16:50:45.719 INFO 9324 --- [9uOLZV0TWJm8g-1] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2018-08-31 16:50:45.720 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2018-08-31 16:50:45.720 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2018-08-31 16:50:45.720 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2018-08-31 16:50:45.720 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Application is null : false
2018-08-31 16:50:45.720 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2018-08-31 16:50:45.720 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2018-08-31 16:50:45.720 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2018-08-31 16:50:45.724 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : The response status is 200
2018-08-31 16:50:45.725 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Not registering with Eureka server per configuration
2018-08-31 16:50:45.726 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1535705445726 with initial instances count: 3
2018-08-31 16:50:46.804 INFO 9324 --- [9uOLZV0TWJm8g-1] o.s.cloud.commons.util.InetUtils : Cannot determine local hostname
2018-08-31 16:50:46.833 INFO 9324 --- [9uOLZV0TWJm8g-1] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:9300/
2018-08-31 16:50:52.619 INFO 9324 --- [9uOLZV0TWJm8g-1] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=config-server, profiles=[dev], label=master, version=34046e96c2c637976b412e1af36e2dc87d713849, state=null
2018-08-31 16:50:52.619 INFO 9324 --- [9uOLZV0TWJm8g-1] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource {name='configService', propertySources=[MapPropertySource {name='configClient'}, MapPropertySource {name='https://github.com/carry-chan/spring-cloud/config-repo/config-server-dev.yml'}]}
2018-08-31 16:50:52.621 INFO 9324 --- [9uOLZV0TWJm8g-1] o.s.boot.SpringApplication : No active profile set, falling back to default profiles: default
2018-08-31 16:50:52.624 INFO 9324 --- [9uOLZV0TWJm8g-1] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@7205494f: startup date [Fri Aug 31 16:50:52 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@6f60de07
2018-08-31 16:50:52.635 INFO 9324 --- [9uOLZV0TWJm8g-1] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-08-31 16:50:52.664 INFO 9324 --- [9uOLZV0TWJm8g-1] o.s.boot.SpringApplication : Started application in 9.372 seconds (JVM running for 2744.746)
2018-08-31 16:50:52.665 INFO 9324 --- [9uOLZV0TWJm8g-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@7205494f: startup date [Fri Aug 31 16:50:52 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@6f60de07
2018-08-31 16:50:52.665 INFO 9324 --- [9uOLZV0TWJm8g-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@6f60de07: startup date [Fri Aug 31 16:50:44 CST 2018]; root of context hierarchy
2018-08-31 16:50:52.666 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Shutting down DiscoveryClient ...
2018-08-31 16:50:52.671 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Completed shut down of DiscoveryClient
2018-08-31 16:50:52.778 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Shutting down DiscoveryClient ...
2018-08-31 16:50:52.785 INFO 9324 --- [9uOLZV0TWJm8g-1] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2018-08-31 16:50:55.789 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Unregistering ...
2018-08-31 16:50:55.800 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : DiscoveryClient_SERVICE-CONFIG-CLIENT/localhost:service-config-client:9400 - deregister status: 200
2018-08-31 16:50:55.844 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Completed shut down of DiscoveryClient
2018-08-31 16:50:55.848 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2018-08-31 16:50:55.851 INFO 9324 --- [9uOLZV0TWJm8g-1] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2018-08-31 16:50:55.851 INFO 9324 --- [9uOLZV0TWJm8g-1] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2018-08-31 16:50:55.851 INFO 9324 --- [9uOLZV0TWJm8g-1] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2018-08-31 16:50:55.851 INFO 9324 --- [9uOLZV0TWJm8g-1] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2018-08-31 16:50:55.955 INFO 9324 --- [9uOLZV0TWJm8g-1] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2018-08-31 16:50:55.956 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2018-08-31 16:50:55.956 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2018-08-31 16:50:55.956 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2018-08-31 16:50:55.956 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Application is null : false
2018-08-31 16:50:55.956 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2018-08-31 16:50:55.956 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2018-08-31 16:50:55.956 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2018-08-31 16:50:55.959 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : The response status is 200
2018-08-31 16:50:55.960 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 30
2018-08-31 16:50:55.962 INFO 9324 --- [9uOLZV0TWJm8g-1] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2018-08-31 16:50:55.963 INFO 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1535705455963 with initial instances count: 3
2018-08-31 16:50:55.966 INFO 9324 --- [9uOLZV0TWJm8g-1] o.s.c.n.e.s.EurekaServiceRegistry : Unregistering application service-config-client with eureka with status DOWN
2018-08-31 16:50:55.967 INFO 9324 --- [9uOLZV0TWJm8g-1] o.s.c.n.e.s.EurekaServiceRegistry : Registering application service-config-client with eureka with status UP
2018-08-31 16:50:55.967 WARN 9324 --- [9uOLZV0TWJm8g-1] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1535705455967, current=UP, previous=DOWN]
2018-08-31 16:50:55.967 INFO 9324 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_SERVICE-CONFIG-CLIENT/localhost:service-config-client:9400: registering service...
2018-08-31 16:50:55.969 INFO 9324 --- [9uOLZV0TWJm8g-1] o.s.cloud.bus.event.RefreshListener : Received remote refresh request. Keys refreshed [config.client.version, server.port, info.profile]
2018-08-31 16:50:55.973 INFO 9324 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_SERVICE-CONFIG-CLIENT/localhost:service-config-client:9400 - registration status: 204
2018-08-31 16:50:55.980 INFO 9324 --- [9uOLZV0TWJm8g-1] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [192.168.68.100:5672]
2018-08-31 16:50:56.011 INFO 9324 --- [9uOLZV0TWJm8g-1] o.s.a.r.c.CachingConnectionFactory : Created new connection: rabbitConnectionFactory.publisher#1ce5511d:0/SimpleConnection@b4fc1ee [delegate=amqp://test@192.168.68.100:5672/, localPort= 52407]
2018-08-31 16:50:56.015 INFO 9324 --- [9uOLZV0TWJm8g-1] o.s.amqp.rabbit.core.RabbitAdmin : Auto-declaring a non-durable, auto-delete, or exclusive Queue (springCloudBus.anonymous.pFKC8gHGT9uOLZV0TWJm8g) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.

Spring Cloud学习笔记【十】配置中心(消息驱动刷新配置)的更多相关文章

  1. Spring Cloud学习笔记【九】配置中心Spring Cloud Config

    Spring Cloud Config 是 Spring Cloud 团队创建的一个全新项目,用来为分布式系统中的基础设施和微服务应用提供集中化的外部配置支持,它分为服务端与客户端两个部分.其中服务端 ...

  2. Spring Cloud 学习笔记(一)——入门、特征、配置

    [TOC] 0 放在前面 0.1 参考文档 http://cloud.spring.io/spring-cloud-static/Brixton.SR7/ https://springcloud.cc ...

  3. Spring Cloud学习笔记-011

    分布式配置中心:安全保护 由于配置中心存储的内容比较敏感,做一定的安全处理是必需的.为配置中心实现安全保护的方式有很多,比如物理网络限制.OAuth2授权等.由于微服务应用和配置中心都构建与Sprin ...

  4. Spring Cloud学习笔记-010

    分布式配置中心:Spring Cloud Config Spring Cloud Config是Spring Cloud团队创建的一个全新的项目,用来为分布式系统中的基础设施和微服务应用提供集中化的外 ...

  5. Spring Cloud学习笔记--Spring Boot初次搭建

    1. Spring Boot简介 初次接触Spring的时候,我感觉这是一个很难接触的框架,因为其庞杂的配置文件,我最不喜欢的就是xml文件,这种文件的可读性很不好.所以很久以来我的Spring学习都 ...

  6. Spring Cloud 学习笔记 (一)-- Eureka 服务器

    开局一张图,截取了本人学习资料中的一张图,很好地展示了Eureka的架构. Eureka服务器 管理服务的作用.细分为服务注册,服务发现. 所有的客户端在Eureka服务器上注册服务,再从Eureka ...

  7. Spring Cloud 学习笔记(二)——Netflix

    4 Spring Cloud Netflix Spring Cloud 通过自动配置和绑定到Spring环境和其他Spring编程模型惯例,为Spring Boot应用程序提供Netflix OSS集 ...

  8. Spring Cloud学习笔记-005

    服务消费者 之前已经搭建好了微服务中的核心组件——服务注册中心(包括单节点模式和高可用模式).也有了服务提供者,接下来搭建一个服务消费者,它主要完成两个目标,发现服务以及消费服务.其中,服务发现的任务 ...

  9. Spring Cloud学习笔记-007

    声明式服务调用:Spring Cloud Feign Feign基于Netflix Feign实现,整合了Spring Cloud Ribbon和Spring Cloud Hystrix,除了提供这两 ...

随机推荐

  1. JavaScript学习——完善注册页面表单校验

    1.之前我们已经使用弹出框的方式实现了表单校验的功能,但是此种方式用户体验效果很差 我们希望做成把提示信息和校验结果放在输入栏的后面. 2.步骤分析 (此案例基于HTML&CSS——网站注册页 ...

  2. centos下nginx配置

    转自  http://www.linuxidc.com/Linux/2016-09/134907.htm 安装所需环境 Nginx 是 C语言 开发,建议在 Linux 上运行,当然,也可以安装 Wi ...

  3. SQL中一次插入多条数据

    SQL中insert一次可以插入一条数据,我们有三种方法可以一次性插入多条数据. 1. 语法:select 字段列表 into 新表 from 源表 注意事项:此种方法新表是系统自动创建,语句执行前不 ...

  4. 脚本_实时显示网卡eth0上的数据流量

    #!bin/bash#功能:使用死循环,实时显示网卡eth0发送的数据包流量#作者:liusingbonwhile : do       echo "本地网卡eth0的数据流量信息如下:&q ...

  5. PHP通过DOM操作XML

    PHP XML操作类DOMDocument属性及方法 注意大小写一定不能弄错. 属性: Attributes 存储节点的属性列表(只读) childNodes 存储节点的子节点列表(只读) dataT ...

  6. BZOJ 2119 股市的预测(后缀数组)

    首先要差分+离散化. 然后就是求形如ABA的串有多少,其中B的长度确定为k. 我们用到了设置关键点的思想.我们枚举A的长度L.然后在\(1,1+L,1+L*2,1+L*3...\)设置关键点.然后我们 ...

  7. [codevs1048]石子归并&[codevs2102][洛谷P1880]石子归并加强版

    codevs1048: 题目大意:有n堆石子排成一列,每次可合并相邻两堆,代价为两堆的重量之和,求把他们合并成一堆的最小代价. 解题思路:经典区间dp.设$f[i][j]$表示合并i~j的石子需要的最 ...

  8. [洛谷P2370]yyy2015c01的U盘

    题目大意:有n个文件,每个文件有一个大小和价值,有一个容量为s的U盘,要装这些文件.传输文件需要接口,一个大小为k的接口能传输的最大文件的大小为k.问最少要多大的接口,才能使传输的文件价值$\ge p ...

  9. C++容器(二):关联容器简介

    关联容器(associative container)与顺序容器的本质区别在于:关联容器通过键(Key)存储和读取元素,而顺序容器则通过元素在容器中的位置顺序存储和访问元素.虽然,关联容器的大部分行为 ...

  10. Android Studio打包.so文件教程

    在eclipse里,.so文件eclipse会帮助我们自动打包进apk文件,通常是放在:libs/armeabi目录,然后把libxxx.so拷贝到这个目录下,这样NDK就会自动把这个libxxx.s ...