-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
One message from Consumer? #1056
Comments
From what I understand you want to achieve queue-like behaviour with Kafka, while Kafka is much more topic oriented.
If possible, for your case it would be good if your topic had more than 1 partition. Then e.g. 2 consumers would split consumption in queue like way. This inly holds if your tasks can be split into different partitions. |
The test scenario I'm trying to reproduce is a scaling one:
What actually happens is that the first consumer receives the first message as expected, takes time to process, and while that is happening the second consumer connects but receives no messages. When the first consumer finally finishes processing the first message and commits it, it immediately receives the second message. This tells me that the first consumer is receiving both messages before the second consumer even starts. |
If topic has only 1 partition, then it is fully expected behaviour. |
Hmm, so is my scenario not possible with Kafka? The idea is that I want to be able to scale up additional workers on-demand (when the queue starts to fill up), but if I only have one worker that has the next N events it doesn't matter if I add additional workers since they are all already filtered to the first worker. I appreciate you taking the time to help out with this as it's appearing it has little to do with the library and more with how Kafka works. |
You can't just achieve queue-like behavior with Kafka with topic with one partition. that's not how Kafka was designed. |
Closing as it's a perfectly explained pattern regarding Kafka arch and not the library. |
I'd like to create a scenario where I'm gathering work tasks from Kafka, so each message may take a long time to run. To that end, I want to only consume one message at a time with the consumer so that another worker that connects would receive the next event in the queue instead of multiple events being buffered to my consumer. I've tried
withMaxPollRecords(1)
, but that didn't seem to make any difference. Is there a way to accomplish this?The text was updated successfully, but these errors were encountered: