Overview
QueueOptions extends QueueBaseOptions and provides configuration for Queue instances.
Interface
interface QueueOptions extends QueueBaseOptions {
defaultJobOptions?: DefaultJobOptions;
streams?: {
events: {
maxLen: number;
};
};
skipMetasUpdate?: boolean;
settings?: AdvancedRepeatOptions;
}
Properties
connection
connection: ConnectionOptions
connection
ConnectionOptions
required
Options for connecting to a Redis instance (ioredis configuration or Redis client instance)
prefix
Prefix for all queue keys in Redis
defaultJobOptions
defaultJobOptions?: DefaultJobOptions
Default options applied to all jobs added to this queue
streams
streams?: {
events: {
maxLen: number;
};
}
Max approximated length for the events stream
skipMetasUpdate?: boolean
If true, the queue will not update metadata. Useful for read-only systems
settings
settings?: AdvancedRepeatOptions
Advanced options for repeatable jobs
skipVersionCheck
skipVersionCheck?: boolean
Avoid validation that Redis version is >= 5.0.0
skipWaitingForReady
skipWaitingForReady?: boolean
Skip waiting for connection to be ready (useful for testing)
telemetry
Telemetry client for distributed tracing and metrics
Examples
Basic Queue
import { Queue } from 'bullmq';
const queue = new Queue('myQueue', {
connection: {
host: 'localhost',
port: 6379,
},
});
With Default Job Options
const queue = new Queue('myQueue', {
connection: {
host: 'localhost',
port: 6379,
},
defaultJobOptions: {
attempts: 3,
backoff: {
type: 'exponential',
delay: 1000,
},
removeOnComplete: 1000,
removeOnFail: 5000,
},
});
With Custom Prefix
const queue = new Queue('myQueue', {
connection: {
host: 'localhost',
port: 6379,
},
prefix: 'myapp', // Keys will be: myapp:myQueue:*
});
With Event Stream Limits
const queue = new Queue('myQueue', {
connection: {
host: 'localhost',
port: 6379,
},
streams: {
events: {
maxLen: 1000, // Keep only 1000 events
},
},
});
Read-Only Queue
const queue = new Queue('myQueue', {
connection: {
host: 'localhost',
port: 6379,
},
skipMetasUpdate: true, // Don't update queue metadata
});
With Shared Connection
import IORedis from 'ioredis';
const connection = new IORedis({
host: 'localhost',
port: 6379,
maxRetriesPerRequest: null,
});
const queue1 = new Queue('queue1', { connection });
const queue2 = new Queue('queue2', { connection });