RabbitMQ实现延迟消费
rabbitMQ没有能直接设置消息延迟消费的功能;
但是可以用消息超时,加入死信队列,进而从另外一个队列中实现消费。达到延迟消费的目的;
需要给原队列设置死信队列,然后消费方,选择设置的死信队列进行消费;
安装运行rabbitMQ见:Docker 运行 RabbitMQ
https://blog.csdn.net/weixin_39617052/article/details/79723849
参考
https://www.cnblogs.com/haoxinyue/p/6613706.html
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
代码send


创建 exchange



创建queue

Queue1设置

Queue2设置

可以查看 Queue1 跟Queue2 变化 跟 输出结果 进行验证(60s后消费)

网友评论