fix 修复 延迟队列在投递消息未到达时间的时候 服务死机导致重启收不到消息
This commit is contained in:
parent
eb946e029d
commit
1186b86f73
@ -224,8 +224,12 @@ public class QueueUtils {
|
||||
/**
|
||||
* 订阅阻塞队列(可订阅所有实现类 例如: 延迟 优先 有界 等)
|
||||
*/
|
||||
public static <T> void subscribeBlockingQueue(String queueName, Consumer<T> consumer) {
|
||||
public static <T> void subscribeBlockingQueue(String queueName, Consumer<T> consumer, boolean isDelayed) {
|
||||
RBlockingQueue<T> queue = CLIENT.getBlockingQueue(queueName);
|
||||
if (isDelayed) {
|
||||
// 订阅延迟队列
|
||||
CLIENT.getDelayedQueue(queue);
|
||||
}
|
||||
queue.subscribeOnElements(consumer);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class DelayedQueueController {
|
||||
QueueUtils.subscribeBlockingQueue(queueName, (String orderNum) -> {
|
||||
// 观察接收时间
|
||||
log.info("通道: {}, 收到数据: {}", queueName, orderNum);
|
||||
});
|
||||
}, true);
|
||||
return R.ok("操作成功");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user