If enable.auto.commit is false, what must you do to commit offsets?

Study for the CCDAK Apache Kafka Test. Use flashcards and multiple choice questions with hints and explanations for each question. Prepare thoroughly for your exam!

Multiple Choice

If enable.auto.commit is false, what must you do to commit offsets?

Explanation:
When enable.auto.commit is false, you must explicitly commit offsets after you've processed the messages. Since automatic offset commits are turned off, the consumer won’t write its position back to Kafka on its own, so your application needs to call commitSync() or commitAsync() once you’ve finished processing the polled records. This gives you control over exactly when your progress is acknowledged, helping you manage failure recovery: if the process crashes before a commit, those messages may be reprocessed on restart; commit after processing ensures you don’t lose the work you’ve completed, while avoiding skipping messages. Enabling auto commit would circumvent this requirement, and doing nothing won’t record progress. Restarting the consumer alone doesn’t commit the offsets either.

When enable.auto.commit is false, you must explicitly commit offsets after you've processed the messages. Since automatic offset commits are turned off, the consumer won’t write its position back to Kafka on its own, so your application needs to call commitSync() or commitAsync() once you’ve finished processing the polled records. This gives you control over exactly when your progress is acknowledged, helping you manage failure recovery: if the process crashes before a commit, those messages may be reprocessed on restart; commit after processing ensures you don’t lose the work you’ve completed, while avoiding skipping messages. Enabling auto commit would circumvent this requirement, and doing nothing won’t record progress. Restarting the consumer alone doesn’t commit the offsets either.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy