一、简介
- 1、发布订阅
SUBSCRIBE, UNSUBSCRIBE 和 PUBLISH 实现了 发布/订阅消息范例,发送者 (publishers) 不用编程就可以向特定的接受者发送消息 (subscribers). Rather, 发布的消息进入通道,不需要知道有没有订阅者. 订阅者发表感兴趣的一个或多个通道,并且只接受他们感兴趣的消息,不管发布者是不是存在. 发布者和订阅者的解耦可以允许更大的伸缩性和更多动态的网络拓扑。 - 2、说明
本篇文章是继:
【SpringBoot】三十四、SpringBoot整合Redis实现序列化存储Java对象
以及
【SpringBoot】三十五、SpringBoot整合Redis监听Key过期事件
其中涉及到的知识及代码,本篇文章不再进行赘述
二、注入消息发布/订阅
- 1、添加消息监听器
/**
* 消息监听
* <p>
* 可以传入多个 MessageLi