Skip to content

Commit

Permalink
更新 消息总线
Browse files Browse the repository at this point in the history
  • Loading branch information
0xcaffebabe committed Mar 17, 2020
1 parent 4eada52 commit 0f4494c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
Binary file added assets/2020317105912.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 20 additions & 13 deletions 软件工程/微服务/SpringCloud/消息总线.md
@@ -1,13 +1,19 @@
![](http://favorites.ren/assets/images/2017/springcloud/configbus2.jpg)
# 消息总线

>微服务架构中,通常会使用轻量级的消息代理来构建一个共用的消息主题来连接各个微服务实例,它广播的消息会被所有在注册中心的微服务实例监听和消费,也称消息总线
![2020317105912](/assets/2020317105912.jpg)

## 使用

- 添加依赖(服务端与客户端

```xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
```
```xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
```

- 配置服务端

Expand All @@ -32,20 +38,21 @@ management:
- 配置客户端

```properties
## 刷新时,关闭安全验证
# 记得rabbitmq服务器信息
# 刷新时,关闭安全验证
management.endpoints.web.exposure.include=bus-refresh
## 开启消息跟踪
# 开启消息跟踪
spring.cloud.bus.trace.enabled=true
```

当配置发生更新时,post调用http://localhost:8003/actuator/bus-refresh
当配置发生更新时,post调用配置中心 <http://config_server:8003/actuator/bus-refresh>

新配置就会传播到所有客户端

# 局部刷新
## 局部刷新

在调用webhook的时候,可以指定参数来指定更新要传播到哪些微服务

# 总线事件
## 总线事件

访问http://127.0.0.1:8003/actuator/trace可以追踪
访问<http://127.0.0.1:8003/actuator/trace>可以追踪

0 comments on commit 0f4494c

Please sign in to comment.