What is a dead letter queue?
## Understanding Dead Letter Queues
### What is a Dead Letter Queue?
A dead letter queue (DLQ) is a pattern in **message-driven** architecture that isolates failed messages into a separate queue. This allows the main flow not to be blocked, prevents data loss, and enables the identification of the error cause and the reprocessing of messages.
### Important Considerations
It is important to understand that `DLQ` does not address the root cause of the failure. Its purpose is to control the storage of failed messages, analyze them, and make decisions about further processing of such messages.
### Example Scenario
#### Microservices Interaction
We have a microservice `Payments`, which publishes an event after a successful payment:
```json
PaymentSucceeded { paymentId, userId, planId, amount, occurredAt }Another microservice Subscriptions listens for this event and creates a subscription in the database and sends a welcome email through a third-party provider upon receiving it.
Failure Handling with DLQ
The simplest scenario where DLQ would be useful is the failure of a third-party API that handles email sending. After receiving a 502 error from the third-party service, we try again 3 more times with a 30-second interval (retry + backoff). If we continue to receive a 502, we send the message to the DLQ. Once the provider is back up, we attempt to process these messages again - this is called DLQ re-drive.
Configure Consent Settings
Cookie Types
- ga*:
- _ga:
Performance Cookies
[Performance] ### Advertising Cookies
[Advertising] ### Uncategorized Cookies
[Uncategorized] Other uncategorized cookies are those that are being analyzed and have not yet been classified into a category. No cookies to display.
Consent Options
- [Reject]
- [Save my settings]
- [Accept all]
Powered by
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.