Spring Cloud Bus结合RabbitMQ消息队列动态刷新配置架构图:
(1)为配置中心Config Server端添加Spring Cloud Bus依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
(2)为配置中心Config Server端配置RabbitMQ消息中间件
spring:
application:
name: MALL-CONFIG
cloud:
config:
server: # Config 服务端配置,增加一个git仓库存放配置文件
git:
uri: https://github.com/lihailin9073/config-repo.git
username: lihailin9073
password: LHLlhl870104
basedir: D:\javasource\config # 指定加载的配置文件存放目录
rabbitmq: # 配置RabbitMQ
host: 39.98.172.148
port: 5672
username: admin
password: 123456
eureka:
client:
service-url:
defaultZone: http://system:sys123@peer1:8761/eureka/ # 单点Eureka Server时使用,将微服务注册到单个Eureka节点上,适合用于本地开发和测试
#defaultZone: http://system:sys123@peer1:8761/eureka/,http://system:sys123@peer2:8762/eureka/,http://system:sys123@peer3:8763/eureka/ # 集群Eureka Server时使用,将微服务注册到集群中的多个Eureka节点上,适合用于线上生产环境
# 暴露监控端点
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
health:
show-details: always
注意必须暴露监控端点,以便后续调用配置中心的/bus-refresh 接口