Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between prefetch count vs no ack in rabbitmq

I need to know what is the difference between prefetch count vs no ack in rabbitmq ?

Also What is the difference between following statements :-

if i set prefetch count say 10 does 10 consumer threads are created ? Or --

if i register 10 cosumers will it create 10 threads ?

Which of the above is more efficient

like image 393
Akshat Avatar asked Nov 15 '25 23:11

Akshat


2 Answers

To answer this specifically for spring-amqp.

prefetchCount=10 means the broker allows up to 10 unacked message for each consumer; it does not affect the number of threads.

Use concurrentConsumers to create multiple consumers - which will have one thread each.

auto ack means the broker doesn't require acks (so you can lose messages). Spring AMQP also blocks deliveries (to prefetch count) if the listener can't keep up.

like image 98
Gary Russell Avatar answered Nov 18 '25 12:11

Gary Russell


Pre-fetch count: How many messages the consumer should read from queue and kept internally rather than picking one message at a time.

No-Ack: Do not acknowledge back that the consumer is done consuming the message.

Those both are used to fine tune your set-up

To address your second part of the question: If you set prefetch count to 10, 10 consumers won't be created, but your single consumer will fetch 10 messages at a time.

And if you create 10 consumers it will most likely create 10 threads (or processes). It all depends on how you configure it. Most likely you will be wanting to use a thread pool though

like image 39
Arun Karunagath Avatar answered Nov 18 '25 12:11

Arun Karunagath



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!