3.1-bus-概述

• Spring Cloud Bus 是用轻量的消息中间件将分布式的节点连接起来,可以用于广播配置文件的更改或者服务的监控管理。关键的思想就是,消息总线可以为微服务做监控,也可以实现应用程序之间相通信。
• Spring Cloud Bus 可选的消息中间件包括 RabbitMQ 和 Kafka
3.2-bus-快速入门
分别在 config-server 和 config-client中引入 bus依赖:bus-amqp 和actuator依赖
<!-- bus --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bus-amqp</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>
分别在 config-server 和 config-client中配置 RabbitMQ
bootstrap.yml
OrderController上添加@RefreshScope注解#配置rabbitmq信息rabbitmq:host: localhostport: 5672username: guestpassword: guestvirtual-host: /
```java @RestController @RequestMapping(“/order”) @RefreshScope public class OrderController {
@Value("${itheima}")private String itheima;...}
3. 在config-server中设置暴露监控断点:bus-refresh<br />application.yml```yaml# 暴露bus的刷新端点management:endpoints:web:exposure:include: 'bus-refresh'
- 启动测试
curl结果中没有信息,说明成功了
curl -X POST http://localhost:9527/actuator/bus-refresh

