spring cloud bus

在MQ上会创建一个 springCloudBus 的 exchange

每个服务都会创建一个 springCloudBus.anonymous.xxx 的队列(queue)
--springCloudBus.anonymous.Bp0n_077SIaJXXZFzGS_hQ

每个queue都会绑定exchange,routingKey 为: #
 -- 意思是接受所有的消息
----------------------


当调用配置刷新时,调用:
POST http://localhost:8081/config/actuator/bus-refresh

会发送一条消息到MQ:
exchange: springCloudBus ,routingKey : springCloudBus

消息内容大概这样:

{"type":"RefreshRemoteApplicationEvent","timestamp":1540780323493,"originService":"config:8081:978efb4c523dc1553ec6df9f86e8574a","destinationService":"customers:9000:**","id":"5cf7d445-0fdb-4666-8017-a4cbbf55f064"}

每个服务(Queue)都会收到该信息,然后每一个都会发送一个确认消息:

{"type":"AckRemoteApplicationEvent","timestamp":1540780484680,"originService":"gateway:8084:5a04db0104b673cb01e9961467796631","destinationService":"**","id":"bbfb9bf2-7cff-4928-9c4f-1d192b04de8c","ackId":"4e320d18-2a58-41e6-aecd-98e0a66faae3","ackDestinationService":"**","event":"org.springframework.cloud.bus.event.RefreshRemoteApplicationEvent"}

这种模式依赖于客户端的消息过滤,如果某个服务的消息量较大,会拖垮其它服务
所以这种模式应该用于配置等一些通用的通道,其它业务消息事件等采用另外一套,不要混合到一起

@StreamListener 注解需要包含在 @Configuration 类中才会被扫描到

引入 bus 会导致  ClasspathLoggingApplicationListener 被触发两次
配置中心也会拉取两次,开启debug,就可以从日志看出来
官方说是正常现象,目前也没发现异常状况

https://stackoverflow.com/questions/48406527/spring-cloud-config-bus-calls-twice-to-the-config-server-when-the-binder-is-cr
https://github.com/spring-cloud/spring-cloud-stream/issues/1188

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值