Bird
Raised Fist0

Which of the following is the correct method to commit offsets synchronously in Kafka's Java consumer API?

easy📝 Syntax Q3 of Q15
Kafka - Message Delivery Semantics
Which of the following is the correct method to commit offsets synchronously in Kafka's Java consumer API?
Aconsumer.commitOffset()
Bconsumer.commitSync()
Cconsumer.commitAsync()
Dconsumer.offsetCommit()
Step-by-Step Solution
Solution:
  1. Step 1: Recall Kafka consumer commit methods

    Kafka's Java consumer API provides commitSync() for synchronous commits.
  2. Step 2: Eliminate incorrect method names

    commitAsync() is asynchronous; commitOffset() and offsetCommit() do not exist.
  3. Final Answer:

    consumer.commitSync() -> Option B
  4. Quick Check:

    Synchronous commit method = commitSync() [OK]
Quick Trick: Use commitSync() for blocking offset commits [OK]
Common Mistakes:
MISTAKES
  • Using commitAsync() when synchronous commit is needed
  • Calling non-existent methods like commitOffset()
  • Confusing method names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes