做项目的时候,有些生产环境对于中间件要求要尽可能少的使用,Redis一般不可或缺,
但是kafka等不让安装....那么,用redis代替kafka,来实现消息队列.
一.先看利用redis的基于pub/sub订阅消费实现的消息队列,这里每个订阅某个主题的消费者都
可以收到该主题中的所有消息.
1.添加项目依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>