Warm tip: This article is reproduced from serverfault.com, please click

Synchronize all consumers of a queue to process only one message at a time

发布于 2020-12-02 12:12:33

I am running a Spring Cloud Stream application, consuming messages from RabbitMq. I want to implement a behaviour where a given queue, having three consumers instances, delivers exactly one message to any of them, and wait for the next to be delivered until the current is acked (some sort of synchronization between all consumers).

I think that this can be done using this https://www.rabbitmq.com/consumer-prefetch.html with global option enabled, but I can't find a way of achieving this using spring cloud stream. Any help will be appreciated.

Questioner
jesantana
Viewed
0
Gary Russell 2020-12-03 00:05:02

Spring uses a separate channel for each consumer so global channel prefetch won't have any effect.

Bear in mind that, even if it was supported, it would only work if the consumers were all in the same instance.