Bird
0
0

To ensure a Kafka consumer commits offsets only after successfully processing a batch of messages, which configuration should be used?

hard📝 Application Q8 of 15
Kafka - Consumers

To ensure a Kafka consumer commits offsets only after successfully processing a batch of messages, which configuration should be used?

ASet <code>enable.auto.commit</code> to true with a low commit interval
BSet <code>auto.offset.reset</code> to latest
CSet <code>max.poll.records</code> to 1
DSet <code>enable.auto.commit</code> to false and commit offsets manually after processing
Step-by-Step Solution
Solution:
  1. Step 1: Understand auto commit behavior

    When enable.auto.commit is true, offsets are committed automatically at intervals, which may commit offsets before processing completes.
  2. Step 2: Manual commit for batch processing

    Setting enable.auto.commit to false allows the application to commit offsets manually after processing a batch successfully.
  3. Step 3: Other options

    auto.offset.reset controls offset reset behavior, max.poll.records controls batch size but not commit behavior, and auto commit with low interval risks premature commits.
  4. Final Answer:

    Set enable.auto.commit to false and commit offsets manually after processing -> Option D
  5. Quick Check:

    Manual commit requires disabling auto commit [OK]
Quick Trick: Disable auto commit to manually commit offsets after processing [OK]
Common Mistakes:
  • Relying on auto commit for batch processing
  • Confusing offset reset with commit control
  • Setting max.poll.records to control commits

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes