我有一个兔子队列,其中我发布了数千条消息。我需要一个背景服务,该服务将:
- 在100条消息的批处理中检索消息,
- 将这些100条消息存储在数据库
- ACK中所有100条消息
- 中,请继续使用我使用RabbitMQ Client的下一批100个消息来
收听消息,但是我不知道如何“批量”。
是否有人有一个有效的例子,说明如何一次将我的Messagess 100-100获取并在将它们保存在DB中后一次ack?
提前很多
I have a RabbitMQ queue in which I post thousands of messages. I need a background Service that will:
- Retrieve the messages in batches of 100 messages
- Store those 100 messages in a Database
- Ack all 100 messages at once
- Proceed with the next batch of 100 messages
I'm using the RabbitMQ Client to listen for messages, but I don't know how to "batch" them.
Does anyone has a working example on how to get my messagess 100-100 at a time and ACK them all at once after they have been saved in a DB?
Thanx a lot in advance
发布评论
评论(1)
您想使用“预摘要”和“多ACK”功能-Prefetch-
这是您在代码中您要做的:
true
,并使用第100条消息的交付标签,从而获得100条消息。You want to use the "prefetch" and "multi ack" features -
This is what you'll do in your code:
true
and use the delivery tag of the 100th message.