Bird
0
0

Which Kafka Streams pattern best supports this?

hard📝 Application Q8 of 15
Kafka - Advanced Stream Processing
You want to ensure that any records causing exceptions during Kafka Streams processing are redirected to a separate "error" topic without stopping the main stream. Which Kafka Streams pattern best supports this?
AUse <code>stream.filter()</code> to remove bad records before processing without logging them.
BConfigure Kafka Streams to automatically retry failed records indefinitely.
CUse a <code>try-catch</code> inside processing logic and produce failed records to a dead-letter topic using a <code>KafkaProducer</code>.
DStop the stream on first exception and restart it after fixing the data.
Step-by-Step Solution
Solution:
  1. Step 1: Catch exceptions during processing

    Wrap processing logic in try-catch to detect failures.
  2. Step 2: Produce failed records to a dead-letter topic

    Use a separate KafkaProducer instance to send problematic records to an error topic for later analysis.
  3. Step 3: Continue processing main stream

    This approach prevents the stream from stopping due to errors.
  4. Final Answer:

    Use a try-catch inside processing logic and produce failed records to a dead-letter topic using a KafkaProducer. -> Option C
  5. Quick Check:

    Use try-catch and dead-letter topic for error handling [OK]
Quick Trick: Redirect errors to dead-letter topic via try-catch [OK]
Common Mistakes:
MISTAKES
  • Relying on automatic retries without handling errors
  • Filtering out bad records without logging
  • Stopping stream on first error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes