From the course: Complete Guide to Apache Kafka for Beginners

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Java consumer auto offset commit behavior

Java consumer auto offset commit behavior - Kafka Tutorial

From the course: Complete Guide to Apache Kafka for Beginners

Java consumer auto offset commit behavior

So one thing that we've been getting for granted is around the consumer offsets. And in the Java Consumer API, whenever you poll regularly, then offsets are going to be regularly committed as well. And this enables at least once reading scenarios by default under certain conditions. So when are the offsets going to be committed? Well, whenever you call poll in the consumer and then the setting auto commit interval millisecond has elapsed. For example, if you have by default, auto commit interval millisecond equals 5,000 and enabled to commit equals true, then it will commit every five seconds. So for example, if you want to be in at least one setting, you need to make sure that all the messages you receive from Kafka are successfully processed before you call poll again. If you don't, then you're not in an at least one scenario because you can go into a scenario where you commit before you actually successfully process the message. And in the rare case you actually disable enable auto…

Contents