Reputation: 3561
To avoid common concurrency problems I have single threaded php consumers that consume several messages from one rabbitMQ queue.
Basically its the same php script executed X times and waiting for new messages.
My question is:
Is correct to assume that as my consumers are single threaded I set a prefetch configuration of 1 message?
Because obviously it wont process more than 1 message at a time...
Right?
Upvotes: 2
Views: 2225
Reputation: 10192
Prefetch is simply a number of messages that the broker will put on the consumer side and remove them only after those messages were acknowledged. Now, if we assume that the client(consumer) is processing one message at the time, then this number prefetch_count is not really important. But, if the clients are consuming messages in one thread, and then spawning new threads - each to process one message, then it's obviously a different story. So one could say that multi-threaded acknowledging is more of a story.
Since you wrote single threaded consumers I'm pretty sure you mean the entire client is single threaded, not just the "consuming" portion, so the my direct answer is you can set it to 1, but you don't have to, it's depending more on the way you are ACKing the messages. I just wanted to elaborate on multi-threaded processing part.
Upvotes: 3