Bird
0
0

Given the following Kafka consumer code snippet, what happens when message processing fails?

medium📝 Predict Output Q13 of 15
Kafka - Event-Driven Architecture
Given the following Kafka consumer code snippet, what happens when message processing fails?
try {
  processMessage(record);
} catch (Exception e) {
  producer.send(new ProducerRecord<>("dlq-topic", record.key(), record.value()));
}
AThe message is silently dropped without notification
BThe message is retried immediately in the same consumer loop
CThe failed message is sent to the "dlq-topic" for later review
DThe consumer stops processing all messages
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the catch block behavior

    When an exception occurs, the code sends the failed message to the "dlq-topic" using a producer.
  2. Step 2: Understand the effect on message processing

    The message is not retried or dropped silently; it is stored in the DLQ topic for later analysis.
  3. Final Answer:

    The failed message is sent to the "dlq-topic" for later review -> Option C
  4. Quick Check:

    Exception handling sends message to DLQ [OK]
Quick Trick: Catch block sends failed messages to DLQ topic [OK]
Common Mistakes:
MISTAKES
  • Assuming immediate retry happens automatically
  • Thinking consumer stops on failure
  • Believing message is dropped silently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes