You want to ensure exactly-once processing in a Kafka consumer application. Which commit strategy is safer and why?
hard📝 Application Q15 of 15
Kafka - Consumers
You want to ensure exactly-once processing in a Kafka consumer application. Which commit strategy is safer and why?
AAuto-commit, because it commits offsets automatically without extra code.
BManual commit, because you commit offsets only after successful processing.
CAuto-commit, because it commits offsets after processing each message.
DManual commit, because it commits offsets before processing messages.
Step-by-Step Solution
Solution:
Step 1: Understand exactly-once processing needs
Exactly-once means processing each message once and committing offset only after success.
Step 2: Compare commit strategies
Auto-commit commits offsets automatically at intervals, risking committing before processing completes. Manual commit lets you commit only after successful processing.
Final Answer:
Manual commit, because you commit offsets only after successful processing. -> Option B
Quick Check:
Exactly-once needs manual commit after success [OK]
Quick Trick:Commit manually after success for exactly-once processing [OK]
Common Mistakes:
Assuming auto-commit guarantees exactly-once
Committing offsets before processing
Ignoring commit timing importance
Master "Consumers" in Kafka
9 interactive learning modes - each teaches the same concept differently