Bird
0
0

How can a Kafka consumer ensure exactly-once processing of messages when consuming from a topic?

hard📝 Application Q9 of 15
Kafka - Consumers
How can a Kafka consumer ensure exactly-once processing of messages when consuming from a topic?
ADisable offset commits and rely on message timestamps
BUse transactions with producer and consumer to commit offsets atomically
CManually commit offsets before processing messages
DProcess messages multiple times to guarantee delivery
Step-by-Step Solution
Solution:
  1. Step 1: Understand exactly-once semantics

    Exactly-once requires atomic commit of message processing and offset committing.
  2. Step 2: Use Kafka transactions

    Kafka supports transactions to atomically commit producer writes and consumer offsets.
  3. Final Answer:

    Use transactions with producer and consumer to commit offsets atomically -> Option B
  4. Quick Check:

    Transactions enable exactly-once processing [OK]
Quick Trick: Use transactions to atomically commit offsets and processing [OK]
Common Mistakes:
  • Committing offsets before processing
  • Disabling commits and trusting timestamps
  • Accepting multiple processing as exactly-once

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes