多个消费者轮询消费数据
2025-4-20
| 2025-4-20
Words 114Read Time 1 min
type
status
date
slug
summary
tags
category
icon
password
当多个消费者同时消费一个队列里面的数据时,采用的是轮询的方法,测试并且看效果。

同一个consumer启动两个程序进行监听

notion image
image-20220901150608863

生产者从控制台输入向消息队列中写入消息

notion image
image-20220901150744920
如果我依次输入A,B,C,D,那么会通过轮询的方式在控制台中打印出来。

输入

notion image
image-20220901151209737

两个消费者输出

notion image
image-20220901151233581
notion image
image-20220901151242373
多数元素复写零
Loading...