Content:
Improve fault tolerance by capturing failed messages that cannot be processed after multiple retries — instead of silently dropping them.
A DLQ (Dead-Letter Queue) is a separate (SQS queue) used to store messages that fail multiple times during processing. When a consumer (such as a Lambda function) tries to process a message and fails repeatedly (based on the (MaxReceiveCount) setting), that message is automatically redirected to the DLQ for later inspection.
This design prevents your main queue and processing logic from being blocked or overwhelmed by problematic messages, and provides a safety net in event-driven systems.
DLQs are essential for building resilient and fault-tolerant architectures. They allow you to:
Prevent data loss
Messages that can’t be processed won’t be deleted or lost — instead, they’re redirected to the DLQ safely.
Investigate message failures
You can inspect failed payloads and metadata in the DLQ to find out why processing failed (e.g., malformed JSON, missing fields, downstream service errors).
Replay messages after fixing issues
After fixing the root cause (e.g., updating code or data structure), you can manually move the message back to the main queue for reprocessing.
Open your main SQS queue
Click Edit
Scroll to the Dead-letter queue section
Configure:
(This means after 3 failed Lambda retries, the message is sent to DLQ)
Temporarily update your (ProcessQuizEvent) Lambda to fail:
Replace your handler code with this:
export const handler = async (event) => {
console.log(" Simulated Failure:", JSON.stringify(event));
throw new Error("Simulated processing failure");
};
This will force every incoming message to fail.
Use your existing flow:
(API Gateway → Lambda → SNS → SQS → Lambda (fails 3 times) → DLQ)
Once testing is complete:
Your architecture is now fault-tolerant and can safely route failing messages to a DLQ for investigation.