Skip to content
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

Safely consuming batch of messages #39

Closed
arnaudbriche opened this issue Oct 22, 2013 · 5 comments
Closed

Safely consuming batch of messages #39

arnaudbriche opened this issue Oct 22, 2013 · 5 comments

Comments

@arnaudbriche
Copy link

Hi,

I'm new to kafka so I might miss something; but here's what I want and think I cannot achieve with the Consumer type.
I'd like to be able to fetch 100 messages, process them, and only then notify Zookeeper that it can move my consumer group offset. This would allow my process to fail in the middle of a batch processing safely: so that the next time I start it, I can start processing the same batch again.
Is this possible with the current state of the library ?

@eapache
Copy link
Contributor

eapache commented Oct 22, 2013

The Consumer type doesn't support moving consumer group offsets at all, because at the time I tried to implement it that part of Kafka was broken anyways so I gave up (presumably it has since been fixed, I haven't checked).

You can achieve what you want by using a Consumer, and counting the messages you process. Every 100 messages, send an OffsetCommitRequest to Kafka with the appropriate data.

@arnaudbriche
Copy link
Author

Ok. Then, should I instanciate a Broker by myself to emit this OffsetCommitRequest, or can I get one from the Consumer object ?

@eapache
Copy link
Contributor

eapache commented Oct 22, 2013

You should get the broker by calling Leader on the Client you used to instantiate the Consumer.

@arnaudbriche
Copy link
Author

Thx eapache.

@sanchitlohia-ovo
Copy link

@eapache How can I reread the same batch again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants