Documentation Index
Fetch the complete documentation index at: https://mintlify.com/taskforcesh/bullmq/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Deduplication in BullMQ delays and deduplicates job execution based on specific identifiers. Within a specified period, or until a job completes or fails, no new jobs with the same identifier will be added to the queue. Instead, these attempts trigger adeduplicated event.
From src/classes/job.ts:160:
Simple Mode
Simple Mode extends deduplication until the job’s completion or failure. While a job remains incomplete, subsequent jobs with the same deduplication ID are ignored.deduplicated event will be emitted.
Simple Mode is useful for long-running jobs or critical updates that must not be duplicated until resolved, such as processing a file upload.
Throttle Mode
Throttle Mode assigns a TTL (Time to Live) to a job. If a similar job is added during this TTL period, it’s ignored, preventing queue overload.customValue added within 5 seconds will be ignored.
From src/types/deduplication-options.ts:
Throttle Mode is useful for scenarios with rapid, repetitive requests, such as multiple users triggering the same job.
Debounce Mode
Debounce Mode delays a job and replaces it with newer versions during the delay period. Only the most recent job is kept and processed.- Each new job with the same deduplication ID replaces the previous job
- The TTL is reset with each addition
- Only the last job data is processed
Debounce Mode is useful when you need the latest data, such as saving user input where only the final state matters.
You must provide a deduplication ID that represents your job. You can hash your entire job data or a subset of attributes to create this identifier.
The Deduplicated Event
Thededuplicated event is emitted whenever a job is deduplicated (ignored or replaced) in any mode.
jobId: The ID of the job retained in the queuededuplicationId: The deduplication ID that caused the deduplicationdeduplicatedJobId: The ID of the job that was deduplicated (ignored or replaced)
Get Deduplication Job Id
Retrieve the ID of the job that started the deduplicated state:Remove Deduplication Key
Stop deduplication before TTL finishes or before a job completes:Remove by Queue
Remove by Job
Only removes if this specific job caused the deduplication:src/classes/job.ts:1538:
Validation
Fromsrc/classes/job.ts:1607:
Comparison Table
| Mode | TTL | Replace | Extend | Use Case |
|---|---|---|---|---|
| Simple | ❌ | ❌ | ❌ | Prevent duplicates until job completes |
| Throttle | ✅ | ❌ | ❌ | Rate limiting, ignore rapid duplicates |
| Debounce | ✅ | ✅ | ✅ | Keep only latest data, discard intermediate updates |
Use Cases
Email Notifications (Simple Mode)
Email Notifications (Simple Mode)
Prevent duplicate password reset emails:
API Rate Limiting (Throttle Mode)
API Rate Limiting (Throttle Mode)
Prevent API spam by throttling requests:
Auto-save (Debounce Mode)
Auto-save (Debounce Mode)
Save only the final state of user edits:
Read More
Add Job API
View the Add Job API Reference
Queue Remove Key
Queue.removeDeduplicationKey API
Job Remove Key
Job.removeDeduplicationKey API
Deduplication Patterns
Deduplication Patterns Guide
