RabbitMQ:只有在确认前一条消息后才能出列下一条消息 [英] RabbitMQ: next message can be dequeued only after previous was acked

查看:77
本文介绍了RabbitMQ:只有在确认前一条消息后才能出列下一条消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 RabbitMQ 的队列上设置这个约束:

在上一条消息(正在处理的消息)被确认之前,队列中的下一条消息不能出列.

通过这个,我将实现事件的有序处理和跨多个队列的并行处理.我/如何为此配置 RabbitMQ?

编辑(澄清):将有许多消费者都试图从所有队列中获取工作,并且由于他们无法从正在处理的事件未被确认的队列中获取工作 - 保持有序处理.

解决方案

在上一条消息(正在处理的消息)被确认之前,队列中的下一条消息不能出列.

您可以通过单个消费者的消费者预取限制来做到这一点.><块引用>

通过这个,我将实现事件的有序处理和跨多个队列的并行处理.

不幸的是,这不会产生您想要的效果.

您可以为个人消费者设置.该消费者将在获得下一条消息之前等待一条消息得到确认.

然而,这适用于个人消费者,而不是队列.

如果你有 2 个消费者,他们每个人都会并行处理一条消息.如果您有 10 个消费者,则将并行处理 10 条消息.

按顺序处理每条消息的唯一方法是让单个消费者预取为 1.

I would like to have this constraint on a queue in RabbitMQ:

Next message in the queue can't be dequeued before previous message (the one being processed) is acked.

Through this I will achieve ordered processing of events and parallel processing across multiple queues. How do I/can I configure RabbitMQ for this?

Edit (clarification): There will be many consumers all trying to get work from all the queues and since they can't get work from a queue that has an event being processed that isn't acked - ordered processing is maintained.

解决方案

Next message in the queue can't be dequeued before previous message (the one being processed) is acked.

you can do this through the consumer prefetch limit for a single consumer.

Through this I will achieve ordered processing of events and parallel processing across multiple queues.

unfortunately, this won't have the effect that you want.

you can set for an individual consumer. that consumer will wait for a message to be acknowledged before getting the next one.

However, this applies to the individual consumer, not the queue.

if you have 2 consumers, each of them will process a message in parallel. if you have 10 consumers, 10 messages will be processed in parallel.

the only way to process every message in order, is to have a single consumer with a prefetch of 1.

这篇关于RabbitMQ:只有在确认前一条消息后才能出列下一条消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆