Bird
0
0

This Kafka consumer code has a bug:

medium📝 Debug Q14 of 15
Kafka - Advanced Stream Processing
This Kafka consumer code has a bug:
consumer.subscribe(['payments'])
for message in consumer:
    process(message)
    # missing commit here

What problem can this cause in complex flows?
AMessages will be lost immediately
BMessages may be processed multiple times after restart
CConsumer will crash on first message
DMessages will be processed out of order
Step-by-Step Solution
Solution:
  1. Step 1: Identify missing commit effect

    Without committing offsets, Kafka does not know messages were processed.
  2. Step 2: Consequence on restart

    Consumer restarts and reprocesses same messages, causing duplicates.
  3. Final Answer:

    Messages may be processed multiple times after restart -> Option B
  4. Quick Check:

    Missing commit = Duplicate processing [OK]
Quick Trick: Always commit offsets to avoid duplicates [OK]
Common Mistakes:
MISTAKES
  • Assuming messages get lost without commit
  • Thinking consumer crashes without commit
  • Believing order is affected by commit

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes