A Dead Letter Queue is a special Kafka topic where messages that cannot be processed successfully are sent. It helps isolate problematic messages for later analysis or reprocessing.
Click to reveal answer
beginner
Why use a Dead Letter Queue pattern?
It prevents the main processing flow from stopping due to bad messages. Instead, those messages are moved to a DLQ so the system can continue working smoothly.
Click to reveal answer
intermediate
How does a message end up in a Dead Letter Queue?
When a consumer fails to process a message after retries or encounters an error it cannot handle, it sends that message to the DLQ topic.
Click to reveal answer
intermediate
What should you do with messages in the Dead Letter Queue?
You should analyze them to find the cause of failure, fix the issue if possible, and then decide whether to reprocess or discard those messages.
Click to reveal answer
advanced
How can you implement a Dead Letter Queue in Kafka?
Create a separate Kafka topic for DLQ. In your consumer code, catch processing errors and produce the failed messages to the DLQ topic with relevant error info.
Click to reveal answer
What is the main purpose of a Dead Letter Queue in Kafka?
ATo speed up message processing
BTo store messages that failed processing
CTo delete old messages automatically
DTo replicate messages across clusters
✗ Incorrect
A Dead Letter Queue stores messages that could not be processed successfully.
When should a message be sent to a Dead Letter Queue?
AAfter successful processing
BBefore sending to the main topic
CWhen processing fails repeatedly
DWhen the consumer is idle
✗ Incorrect
Messages are sent to the DLQ after processing fails repeatedly or cannot be handled.
Which Kafka component typically sends messages to the Dead Letter Queue?
AZookeeper
BBroker
CProducer
DConsumer
✗ Incorrect
The consumer sends failed messages to the DLQ after processing errors.
What is a good practice after messages land in the Dead Letter Queue?
AAnalyze and fix issues
BIgnore them
CDelete the DLQ topic
DSend them back to the producer
✗ Incorrect
Analyzing and fixing issues helps improve system reliability.
How do you create a Dead Letter Queue in Kafka?
ACreate a new topic for failed messages
BUse the same topic for all messages
CConfigure Zookeeper to handle failures
DSet consumer timeout to zero
✗ Incorrect
A separate topic is created to hold failed messages as the DLQ.
Explain the Dead Letter Queue pattern and why it is useful in Kafka message processing.
Think about what happens when a message can't be processed.
You got /4 concepts.
Describe how you would implement a Dead Letter Queue in a Kafka consumer application.
Focus on the consumer's role and error handling.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a Dead Letter Queue (DLQ) in Kafka?
easy
A. To store messages that failed processing for later analysis
B. To speed up message processing by duplicating messages
C. To permanently delete messages after processing
D. To encrypt messages before sending to consumers
Solution
Step 1: Understand the role of DLQ
A Dead Letter Queue is used to hold messages that cannot be processed successfully by the main consumer.
Step 2: Identify the purpose of storing failed messages
Storing failed messages allows developers to analyze and fix issues without blocking the main processing flow.
Final Answer:
To store messages that failed processing for later analysis -> Option A
Quick Check:
DLQ = store failed messages [OK]
Hint: DLQ holds failed messages to avoid blocking main flow [OK]
Common Mistakes:
Thinking DLQ speeds up processing by duplicating messages
Confusing DLQ with message deletion
Assuming DLQ encrypts messages
2. Which Kafka configuration is commonly used to specify the Dead Letter Queue topic for a consumer?
easy
A. enable.auto.commit
B. auto.offset.reset
C. max.poll.records
D. dead.letter.queue.topic.name
Solution
Step 1: Identify DLQ related configuration
The configuration dead.letter.queue.topic.name is used to specify the topic where failed messages are sent.
Step 2: Differentiate from other common configs
Other options like enable.auto.commit and auto.offset.reset control offset behavior, not DLQ.
B. The producer.send method is missing a ProducerRecord object
C. The process method should not be inside try-catch
D. The record.key() cannot be used as a message key
Solution
Step 1: Check the producer.send method usage
The producer.send method requires a ProducerRecord object, not separate parameters.
Step 2: Identify correct usage
The correct call is producer.send(new ProducerRecord<>("dlq-topic", record.key(), record.value()));
Final Answer:
The producer.send method is missing a ProducerRecord object -> Option B
Quick Check:
producer.send needs ProducerRecord object [OK]
Hint: producer.send requires ProducerRecord, not separate args [OK]
Common Mistakes:
Passing topic and data as separate arguments to send
Ignoring exception handling best practices
Misusing record key as invalid
5. You want to implement a Dead Letter Queue pattern in Kafka that retries failed messages up to 3 times before sending them to the DLQ. Which approach correctly achieves this?
hard
A. Use a retry counter in message headers; on failure increment and retry, else send to DLQ after 3 tries
B. Send all failed messages immediately to DLQ without retries
C. Configure Kafka broker to automatically retry messages 3 times before DLQ
D. Use a separate consumer that deletes messages after 3 retries
Solution
Step 1: Understand retry logic with DLQ
Retries require tracking how many times a message was processed; using headers to count retries is common.
Step 2: Implement conditional retry or DLQ send
If retry count is less than 3, retry processing; if 3 or more, send message to DLQ topic.
Step 3: Evaluate other options
Kafka broker does not handle retries automatically; immediate DLQ send skips retries; deleting messages after retries is incorrect.
Final Answer:
Use a retry counter in message headers; on failure increment and retry, else send to DLQ after 3 tries -> Option A
Quick Check:
Retry count in headers controls DLQ after 3 tries [OK]
Hint: Track retries in headers; send to DLQ after max retries [OK]
Common Mistakes:
Expecting Kafka broker to retry automatically
Sending all failures immediately to DLQ
Deleting messages instead of sending to DLQ
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.