Bird
0
0

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

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

    Kafka's Java consumer API provides commitSync() for synchronous commits and commitAsync() for asynchronous commits.
  2. Step 2: Identify the synchronous commit method

    commitSync() is the correct method to commit offsets synchronously; others are invalid method names.
  3. Final Answer:

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

    Synchronous commit method = commitSync() [OK]
Quick Trick: Use commitSync() for synchronous offset commits [OK]
Common Mistakes:
  • Using commitAsync() for synchronous commit
  • Calling non-existent commitOffset() method
  • Confusing commitNow() with commitSync()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes