Menu

BullMQ in NestJS: Retries, Idempotency and Dead-Letter Queues
📰

BullMQ in NestJS: Retries, Idempotency and Dead-Letter Queues

DEV Community: redis·MUHAMMAD ZAIN UL ABIDIN·5 days ago
#5hw7jRuP
#devtoredis#devto#dev#queue#bullmq
Reading 0:00
15s threshold

A queue that retries blindly is worse than no queue at all. It double-sends the welcome email, double-charges the customer, and then deletes the evidence by retrying the same broken job until the failure looks like noise. This post builds the setup I actually run in NestJS: retries that back off with jitter, jobs that cannot run twice, and a dead-letter queue that keeps every terminal failure inspectable and replayable.

I learned this the way most backend lessons arrive: a welcome email went out three times. The endpoint that sent it called the mail provider directly, the provider timed out once, and my retry logic ran the whole send again instead of checking whether the first attempt had landed. The user got three identical emails, support got a ticket, and I got a rule I have kept since: a background job is only safe to retry if running it twice is harmless, and a job that fails for good must land somewhere a human can find it.

That is what this post builds, in one NestJS module.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.