Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RabbitMQ: next message can be dequeued only after previous was acked

Tags:

rabbitmq

mq

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.

like image 501
ytoledano Avatar asked Jan 19 '26 04:01

ytoledano


1 Answers

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.

like image 75
Derick Bailey Avatar answered Jan 21 '26 08:01

Derick Bailey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!