A worker generates a report and saves it to the database. It then crashes before BullMQ records the job as complete. A second worker may process the job again. How do you guarantee at-most-once output under at-least-once delivery?
Key Takeaway: Pair a deterministic BullMQ jobId in Redis with a UNIQUE database constraint and INSERT ... ON CONFLICT DO NOTHING in PostgreSQL. Queue deduplication stops overlapping enqueues while active, and the database constraint prevents duplicates after job retention expires or a worker crashes mid-ack.
Enforce the request ID at both the queue and database boundaries
Assign a stable requestId when the HTTP API accepts work.…