A dead letter queue can safely isolate bad data, provided retries, retention periods, and an on-call owner are all set up properly.
Key takeaways
- Kafka Connect stops by default when it encounters an error. With errors.tolerance=all set, the connector silently drops bad records without logging them. Both scenarios are dangerous for customer data.
- A DLQ is only safe when three conditions are met: retries are sufficient to absorb transient errors, the DLQ's retention period is longer than the source queue's, and the DLQ topic has subscribers.
- A DLQ is a debugging tool: always write the failure reason into the message, make sure someone actually looks at it, and replay after the fault is fixed.
At 2 a.m., a retail customer calls: the orders table in their data warehouse hasn't been updated since early evening. The cause is a single record with a malformed date field. The connector stops when it hits it, and tens of thousands of perfectly valid records behind it get stuck too.
Many engineers' first instinct is to enable error skipping to get the pipeline running again. That leads to the second problem: a month later, the customer's finance team finds the revenue numbers don't reconcile, and no one can explain why, because all traces of that record are gone.
Working on-site as a Forward Deployed Engineer (FDE), this dilemma comes up again and again: the pipeline can't stop, but the data can't be lost either. A dead letter queue (DLQ) solves this—provided you know exactly where it can go wrong.
Whether you stop or skip, the customer loses either way
When a message can't be processed, the system has only three options: stop, skip, or divert it elsewhere. Kafka Connect stops by default. With
errors.tolerance=all
set, the connector switches to skipping bad records—an approach a Confluent analysis calls "YOLO."
"Silently" here is meant literally. According to Confluent, once error tolerance is enabled, the connector by default does not log the messages it drops. Without a DLQ or logging configured, data can vanish without you ever knowing.
The third option is to move the record into a separate queue. AWS's SQS documentation positions the DLQ first and foremost as a debugging tool: isolate messages that can't be consumed so you can find out why processing failed. Treat the DLQ as an isolation ward with a doctor on duty, not a garbage bin.
An orders pipeline, configured line by line
Back to that retail customer: orders flow into the data warehouse via Kafka Connect. A reasonable configuration for this connector looks like this:
errors.tolerance=all errors.deadletterqueue.topic.name=dlq-orders-sink errors.deadletterqueue.context.headers.enable=true errors.log.enable=true
The third line is the most valuable. Kafka Connect can write the reason a message was rejected into that message's own header. When you open the DLQ the next morning, you can see at a glance which record failed and why—no need to rerun the pipeline and guess.
As mentioned above, once tolerance is enabled, the connector by default doesn't log dropped messages. The last line keeps a copy in the logs in addition to the DLQ, so data loss never happens silently.
On Confluent Cloud, serialization/deserialization (serde) errors also don't stop the connector: it keeps running and sends the failed records to the DLQ topic.
Now suppose the customer's order processing moves to SQS. The key number here is the
maxReceiveCount
in the redrive policy—how many times a consumer may receive a message before it is moved to the DLQ:
{
"deadLetterTargetArn": "arn:aws:sqs:...:orders-dlq",
"maxReceiveCount": 5
}AWS recommends leaving plenty of room for retries. If you set this value to 1, a single failure—say, a database hiccup lasting a few seconds—pushes the message into the DLQ. The result: the DLQ fills up with perfectly valid orders, and the few genuinely problematic records drown among them.
Get the retention period wrong, and messages are lost
The hardest trap to spot is the retention period. In an SQS standard queue, a message moved to the DLQ keeps the timestamp from when it entered the source queue. That's why AWS recommends the DLQ's retention period always be longer than the source queue's.
A hypothetical example: both queues retain messages for 4 days. An order enters the queue on day 0, retries until day 3, and is finally moved to the DLQ.
The clock doesn't restart, so only 1 day remains for investigation. If that day falls on a weekend, the message may expire before anyone even opens it.
Google Pub/Sub has a different trap. The maximum delivery attempts before a message is forwarded to the dead letter topic must be an integer between 5 and 100. But if the dead letter topic has no subscription, forwarded messages are lost—which is why Google's documentation reminds you to add a subscription to that topic.
| Platform | Settings to adjust | Where data gets lost |
|---|---|---|
| SQS | maxReceiveCount, DLQ retention period | DLQ retention period equal to or shorter than the source queue |
| Kafka Connect | errors.tolerance, DLQ topic, failure-reason header | Tolerance enabled but no DLQ or logging |
| Pub/Sub | Maximum delivery attempts, 5 to 100 | Dead letter topic with no subscription |
What's the rollout order on-site?
Start by asking the customer one question: does message ordering matter to them? AWS warns that if you don't want to disrupt strict ordering of messages or operations, don't attach a DLQ to a FIFO queue. A stream of account balance updates and an event log stream are completely different things, and this answer determines the entire design.
Next, set the retry count based on the transient error types common in the customer's systems. Set the DLQ's retention period longer than the source queue's, enable failure-reason logging, and confirm the DLQ has subscribers or consumers. Then set up alerts for new messages appearing in the DLQ, and agree with the customer on who receives them.
The final step is the runbook. On SQS, once investigation is complete, you can use DLQ redrive to send messages back. The correct order is: look at the cause first, fix the code or data, then replay. Do it in reverse, and the messages just go around the loop again and land back in the DLQ.
Mistakes that recur across projects
The most common one is treating the DLQ as a checkbox: it's configured, but there are no alerts, no owner, and no one opens it for weeks.
The second is setting retries too low, so the DLQ fills up with transient errors. Then there are the retention period and subscription issues described above—both lose messages without any warning.
There's also a communication mistake: not telling the customer the DLQ exists. Put the DLQ's record count into your regular reports. Reading "12 records had malformed dates, fixed and reprocessed" builds far more trust than the customer stumbling on their own over a revenue number no one can explain.
From a career perspective, this skill is worth stating clearly on your resume. Instead of "built data pipelines," write that you designed DLQ-based error handling for production systems, complete with a replay runbook. When a system design interview asks "what if a record is corrupted?", don't just answer "retry."
Name all three settings: retries sufficient to absorb transient errors; a DLQ retention period longer than the source queue's; and the failure reason written into the header, with a subscription in place so the DLQ actually gets looked at.
This week's exercise
Set up a test queue with a DLQ, then deliberately send a message that violates the schema. Track its retries one by one, read the failure reason in the DLQ, fix the consumer, replay, and confirm the message reaches its destination.
Once you've walked through this full loop, the next time a customer calls at 2 a.m., you'll be able to point precisely to where every failed record is.
Was this article helpful?
Thanks for your feedback!