Skip to main content
When you need to add many jobs at once, using addBulk is more efficient than adding them one by one. This method reduces the number of roundtrips to Redis and ensures all jobs are added atomically.

Method Signature

array
required
An array of job definitions. Each job is defined by three properties: name, data, and opts. They follow the same signature as Queue.add.

Basic Usage

Adding Jobs with Options

Each job in the bulk array can have its own options, just like when using add:

Job Options

The opts field for each job in the bulk array supports all the same options as the regular add method, except for the repeat option:
number
Delay in milliseconds before the job can be processed
number
Job priority (0 is highest priority)
number
Number of retry attempts
number | BackoffOptions
Backoff settings for retries
boolean
Add to right of queue (LIFO) instead of left (FIFO)
boolean | number | KeepJobs
Auto-remove job on completion
boolean | number | KeepJobs
Auto-remove job on failure
string
Custom job ID (must be unique)
ParentOptions
Parent job options for flows
The repeat option is not available in addBulk. For repeatable jobs, use the regular add method or upsertJobScheduler.

Atomicity

The addBulk operation is atomic, meaning it will either succeed and add all jobs, or fail and add none of them:

Performance Benefits

Using addBulk provides significant performance improvements when adding multiple jobs:
  • Reduced Network Roundtrips: One network call instead of many
  • Atomic Operation: All-or-nothing guarantees
  • Better Throughput: Can add thousands of jobs quickly

Example: Adding Many Jobs

Practical Example: Batch Notifications