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

How to disable auto.commit #540

Open
yordis opened this issue Nov 24, 2022 · 3 comments
Open

How to disable auto.commit #540

yordis opened this issue Nov 24, 2022 · 3 comments

Comments

@yordis
Copy link

yordis commented Nov 24, 2022

I have been trying to figure out how to disable auto.commit, I searched the docs and the code and tried to figure it out, but I am unfamiliar with the subject.

I would appreciate it if the documentation mentions such a setup since it is an important one we are trying to disable to ensure we do not lose messages.

Thanks in advanced.

@zmstone
Copy link
Contributor

zmstone commented Dec 5, 2022

Hi @yordis
do you mean you want to control when to commit offset?

if you use the v2 group subscriber, you can make the handle message callback return ack instead of commit.
https://github.com/kafka4beam/brod/blob/master/src/brod_group_subscriber_worker.erl#L79
Then call the async commit API when it's ready to commit:
https://github.com/kafka4beam/brod/blob/master/src/brod_group_subscriber_v2.erl#L191-L194

@yordis
Copy link
Author

yordis commented Dec 5, 2022

do you mean you want to control when to commit offset?

Something around the topic,

From https://docs.confluent.io/platform/current/clients/consumer.html#offset-management

By default, the consumer is configured to auto-commit offsets. Using auto-commit gives you “at least once” delivery: Kafka guarantees that no messages will be missed, but duplicates are possible. Auto-commit basically works as a cron with a period set through the auto.commit.interval.ms configuration property.

That may cause data loss in case of some processing issue, so I am trying to figure out how to disable the auto.commit all together

@zmstone
Copy link
Contributor

zmstone commented Jan 1, 2023

do you mean you want to control when to commit offset?

Something around the topic,

From https://docs.confluent.io/platform/current/clients/consumer.html#offset-management

By default, the consumer is configured to auto-commit offsets. Using auto-commit gives you “at least once” delivery: Kafka guarantees that no messages will be missed, but duplicates are possible. Auto-commit basically works as a cron with a period set through the auto.commit.interval.ms configuration property.

That may cause data loss in case of some processing issue, so I am trying to figure out how to disable the auto.commit all together

That looks like a Java client behavior, and I am not entirely sure if it actually means it may cause data loss.
brod never does this.

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

2 participants