Skip to main content
InterviewHubPRO
Section Overview
Q20

Question 20 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

40%
Apache Kafka Streaming (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

How do you handle Poison Pill Messages in Kafka using Dead Letter Topics (DLT)?

senior LevelSystem DesignApache KafkaMicroservices

In Simple Words: A Poison Pill is a corrupted, unparseable, or schema-violating message that causes the consumer deserializer to throw an unhandled exception. If the consumer crashes and restarts, it fetches the exact same offset again and crashes in an infinite loop!

DLT Architecture Blueprint:

  1. Wrap message deserialization and processing in a strict try-catch block.
  2. If deserialization or business processing fails after a configured retry threshold (e.g. 3 attempts with exponential backoff):
    • Publish the failed message, along with the stack trace, error reason, and original partition/offset in headers, to a Dead Letter Topic (e.g., orders-dlt).
    • Commit the original offset so the consumer can advance to the next valid record.
  3. Alert engineering teams via PagerDuty/Datadog to inspect and replay DLT records after fixing the bug.