Bird
0
0

What will happen if you call consumer.commitSync() immediately after poll() without processing any records?

medium📝 Predict Output Q5 of 15
Kafka - Consumers
What will happen if you call consumer.commitSync() immediately after poll() without processing any records?
AOffsets will be committed for the last polled records
BAn exception will be thrown
CNothing happens, no offsets committed
DConsumer will reset to earliest offset
Step-by-Step Solution
Solution:
  1. Step 1: Understand commitSync behavior

    commitSync() commits the offsets of the last records returned by poll(), even if no processing done.
  2. Step 2: Confirm no exception or reset occurs

    Calling commitSync() without processing does not throw exceptions or reset offsets.
  3. Final Answer:

    Offsets will be committed for the last polled records -> Option A
  4. Quick Check:

    commitSync() commits last polled offsets [OK]
Quick Trick: commitSync() commits last poll offsets even if unprocessed [OK]
Common Mistakes:
  • Expecting exception if no processing
  • Thinking commitSync resets offsets
  • Assuming no commit happens without processing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes