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

jobs
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:
opts.delay
number
Delay in milliseconds before the job can be processed
opts.priority
number
Job priority (0 is highest priority)
opts.attempts
number
Number of retry attempts
opts.backoff
number | BackoffOptions
Backoff settings for retries
opts.lifo
boolean
Add to right of queue (LIFO) instead of left (FIFO)
opts.removeOnComplete
boolean | number | KeepJobs
Auto-remove job on completion
opts.removeOnFail
boolean | number | KeepJobs
Auto-remove job on failure
opts.jobId
string
Custom job ID (must be unique)
opts.parent
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