Skip to main content

BullMQPluginOptions

Configuration options for the BullMQJobQueuePlugin.

Signature
interface BullMQPluginOptions {    connection?: ConnectionOptions;    queueOptions?: Omit<QueueOptions, 'connection'>;    workerOptions?: Omit<WorkerOptions, 'connection'>;    setRetries?: (queueName: string, job: Job) => number;    setBackoff?: (queueName: string, job: Job) => BackoffOptions | undefined;    setJobOptions?: (queueName: string, job: Job) => BullJobsOptions;}

connection

propertyConnectionOptions

Connection options which will be passed directly to BullMQ when creating a new Queue, Worker and Scheduler instance.

If omitted, it will attempt to connect to Redis at 127.0.0.1:6379.

queueOptions

propertyOmit<QueueOptions, 'connection'>

Additional options used when instantiating the BullMQ Queue instance. See the BullMQ QueueOptions docs

workerOptions

propertyOmit<WorkerOptions, 'connection'>

Additional options used when instantiating the BullMQ Worker instance. See the BullMQ WorkerOptions docs

setRetries

property(queueName: string, job: Job) => numberv1.3.0

When a job is added to the JobQueue using JobQueue.add(), the calling code may specify the number of retries in case of failure. This option allows you to override that number and specify your own number of retries based on the job being added.

Example

Ts
setRetries: (queueName, job) => {  if (queueName === 'send-email') {    // Override the default number of retries    // for the 'send-email' job because we have    // a very unreliable email service.    return 10;  }  return job.retries;}

setBackoff

property(queueName: string, job: Job) => BackoffOptions | undefinedv1.3.0
Default:'exponential', 1000

This allows you to specify the backoff settings when a failed job gets retried. In other words, this determines how much time should pass before attempting to process the failed job again. If the function returns undefined, the default value of exponential/1000ms will be used.

Example

Ts
setBackoff: (queueName, job) => {  return {    type: 'exponential', // or 'fixed'    delay: 10000 // first retry after 10s, second retry after 20s, 40s,...  };}

setJobOptions

property(queueName: string, job: Job) => BullJobsOptionsv3.2.0

This allows you to specify additional options for a job when it is added to the queue. The object returned is the BullMQ JobsOptions type, which includes control over settings such as delay, attempts, priority and much more.

This function is called every time a job is added to the queue, so you can return different options based on the job being added.

Example

Ts
// Here we want to assign a higher priority to jobs in the 'critical' queuesetJobOptions: (queueName, job) => {  const priority = queueName === 'critical' ? 1 : 5;  return { priority };}

Configuration for the backoff function when retrying failed jobs.

Signature
interface BackoffOptions {    type: 'exponential' | 'fixed';    delay: number;}

type

property'exponential' | 'fixed'

delay

propertynumber
Was this chapter helpful?
Report Issue
Edited Feb 2, 2026·Edit this page