Problem Statement
Messages that fail processing in the event bus are silently dropped with no retry or inspection path. Implement a dead letter queue (DLQ) that captures failed messages with full error context, supports configurable retry with exponential backoff, and provides management API for inspection, replay, and purging.
Technical Bounds
- Max retries: 3 (exponential backoff: 30s, 2min, 10min).
- DLQ storage: PostgreSQL table with TTL of 14 days; partitioned by day.
- Error context: original message body, error type, stack trace, retry count, failed_at, consumer_id.
- Management API:
GET /dlq (list, filter), POST /dlq/{id}/retry, POST /dlq/purge.
- Alert: PagerDuty when DLQ depth > 500 for > 5 minutes.
Steps
- Add retry logic to message consumer: on processing error, increment retry_count, re-enqueue with backoff delay.
- On 3rd failure, move message from queue to
dead_letter_queue table with full error context.
- Implement management API endpoints for inspection and retry.
- Add scheduled job: daily purge of DLQ entries older than 14 days.
- Add monitoring:
dlq_depth gauge, dlq_enqueue_total counter.
- Integration test: submit 10 messages to a consumer that always fails, verify all land in DLQ after 3 retries.
Problem Statement
Messages that fail processing in the event bus are silently dropped with no retry or inspection path. Implement a dead letter queue (DLQ) that captures failed messages with full error context, supports configurable retry with exponential backoff, and provides management API for inspection, replay, and purging.
Technical Bounds
GET /dlq(list, filter),POST /dlq/{id}/retry,POST /dlq/purge.Steps
dead_letter_queuetable with full error context.dlq_depthgauge,dlq_enqueue_totalcounter.