Skip to main content
Version: 0.1.2

Queue

BullMQ-based job queue system

Classes

Job

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:15

Job

This class represents a Job in the queue. Normally job are implicitly created when you add a job to the queue with methods such as Queue.addJob( ... )

A Job instance is also passed to the Worker's process function.

Type Parameters

DataType

DataType = any

ReturnType

ReturnType = any

NameType

NameType extends string = string

Implements

  • MinimalJob<DataType, ReturnType, NameType>

Constructors

Constructor
new Job<DataType, ReturnType, NameType>(
queue,
name,
data,
opts?,
id?): Job<DataType, ReturnType, NameType>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:138

Parameters
queue

MinimalQueue

name

NameType

The name of the Job

data

DataType

The payload for this job.

opts?

JobsOptions

The options object for this job.

id?

string

Returns

Job<DataType, ReturnType, NameType>

Properties

attemptsMade
attemptsMade: number;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:75

Number of attempts after the job has failed.

Default Value
0
Implementation of
MinimalJob.attemptsMade
attemptsStarted
attemptsStarted: number;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:70

Number of attempts when job is moved to active.

Default Value
0
data
data: DataType;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:24

The payload for this job.

Implementation of
MinimalJob.data
debounceId?
optional debounceId: string;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:110

Debounce identifier.

Deprecated

use deduplicationId

deduplicationId?
optional deduplicationId: string;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:114

Deduplication identifier.

deferredFailure
deferredFailure: string;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:89

Deferred failure. Stores a failed message and marks this job to be failed directly as soon as the job is picked up by a worker, and using this string as the failed reason.

delay
delay: number;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:54

An amount of milliseconds to wait until this job can be processed.

Default Value
0
Implementation of
MinimalJob.delay
discarded
protected discarded: boolean;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:136

Deprecated

use UnrecoverableError

failedReason
failedReason: string;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:84

Reason for failing.

Implementation of
MinimalJob.failedReason
finishedOn?
optional finishedOn: number;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:93

Timestamp for when the job finished (completed or failed).

Implementation of
MinimalJob.finishedOn
id?
optional id: string;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:29

Implementation of
MinimalJob.id
name
name: NameType;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:20

The name of the Job

Implementation of
MinimalJob.name
nextRepeatableJobId?
optional nextRepeatableJobId: string;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:123

Produced next repetable job Id.

opts
opts: JobsOptions;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:28

The options object for this job.

Implementation of
MinimalJob.opts
parent?
optional parent: ParentKeys;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:105

Object that contains parentId (id) and parent queueKey.

Implementation of
MinimalJob.parent
parentKey?
optional parentKey: string;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:101

Fully qualified key (including the queue prefix) pointing to the parent of this job.

Implementation of
MinimalJob.parentKey
priority
priority: number;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:61

Ranges from 0 (highest priority) to 2 097 152 (lowest priority). Note that using priorities has a slight impact on performance, so do not use it if not required.

Default Value
0
processedBy?
optional processedBy: string;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:131

The worker name that is processing or processed this job.

processedOn?
optional processedOn: number;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:97

Timestamp for when the job was processed.

Implementation of
MinimalJob.processedOn
progress
progress: JobProgress;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:39

The progress a job has performed so far.

Default Value
0
Implementation of
MinimalJob.progress
queue
protected queue: MinimalQueue;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:16

queueQualifiedName
readonly queueQualifiedName: string;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:34

It includes the prefix, the namespace separator :, and queue name.

See

https://www.gnu.org/software/gawk/manual/html_node/Qualified-Names.html

Implementation of
MinimalJob.queueQualifiedName
repeatJobKey?
optional repeatJobKey: string;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:118

Base repeat job key.

Implementation of
MinimalJob.repeatJobKey
returnvalue
returnvalue: ReturnType;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:44

The value returned by the processor when processing this job.

Default Value
null
Implementation of
MinimalJob.returnvalue
scripts
protected scripts: Scripts;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:137

stacktrace
stacktrace: string[];

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:49

Stacktrace for the error (for failed jobs).

Default Value
null
Implementation of
MinimalJob.stacktrace
stalledCounter
stalledCounter: number;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:80

Number of times where job has stalled.

Default Value
0
timestamp
timestamp: number;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:65

Timestamp when the job was created (unless overridden with job options).

Implementation of
MinimalJob.timestamp
token?
optional token: string;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:127

The token used for locking this job.

toKey()
protected toKey: (type) => string;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:132

Parameters
type

string

Returns

string

Accessors

prefix
Get Signature
get prefix(): string;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:331

Returns

string

the prefix that is used.

Implementation of
MinimalJob.prefix
queueName
Get Signature
get queueName(): string;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:327

Returns

string

the queue name this job belongs to.

Implementation of
MinimalJob.queueName

Methods

addJob()
addJob(client, parentOpts?): Promise<string>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:481

Adds the job to Redis.

Parameters
client

RedisClient

parentOpts?

ParentKeyOpts

Returns

Promise<string>

asJSON()
asJSON(): JobJson;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:208

Prepares a job to be serialized for storage in Redis.

Returns

JobJson

Implementation of
MinimalJob.asJSON
asJSONSandbox()
asJSONSandbox(): JobJsonSandbox;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:214

Prepares a job to be passed to Sandbox.

Returns

JobJsonSandbox

Implementation of
MinimalJob.asJSONSandbox
changeDelay()
changeDelay(delay): Promise<void>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:353

Change delay of a delayed job.

Reschedules a delayed job by setting a new delay from the current time. For example, calling changeDelay(5000) will reschedule the job to execute 5000 milliseconds (5 seconds) from now, regardless of the original delay.

Parameters
delay

number

milliseconds from now when the job should be processed.

Returns

Promise<void>

void

Throws

JobNotExist This exception is thrown if jobId is missing.

Throws

JobNotInState This exception is thrown if job is not in delayed state.

changePriority()
changePriority(opts): Promise<void>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:360

Change job priority.

Parameters
opts

options containing priority and lifo values.

lifo?

boolean

priority?

number

Returns

Promise<void>

void

clearLogs()
clearLogs(keepLogs?): Promise<void>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:245

Clears job's logs

Parameters
keepLogs?

number

the amount of log entries to preserve

Returns

Promise<void>

createScripts()
protected createScripts(): void;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:182

Returns

void

discard()
discard(): void;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:471

Marks a job to not be retried if it fails (even if attempts has been configured)

Returns

void

Deprecated

use UnrecoverableError

extendLock()
extendLock(token, duration): Promise<number>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:271

Extend the lock for this job.

Parameters
token

string

unique token for the lock

duration

number

lock duration in milliseconds

Returns

Promise<number>

getChildrenValues()
getChildrenValues<CT>(): Promise<{
[jobKey: string]: CT;
}>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:369

Get this jobs children result values if any.

Type Parameters
CT

CT = any

Returns

Promise<{ [jobKey: string]: CT; }>

Object mapping children job keys with their values.

getDependencies()
getDependencies(opts?): Promise<{
failed?: string[];
ignored?: Record<string, any>;
nextFailedCursor?: number;
nextIgnoredCursor?: number;
nextProcessedCursor?: number;
nextUnprocessedCursor?: number;
processed?: Record<string, any>;
unprocessed?: string[];
}>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:403

Get children job keys if this job is a parent and has children.

Parameters
opts?

DependenciesOpts

Returns

Promise<{ failed?: string[]; ignored?: Record<string, any>; nextFailedCursor?: number; nextIgnoredCursor?: number; nextProcessedCursor?: number; nextUnprocessedCursor?: number; processed?: Record<string, any>; unprocessed?: string[]; }>

dependencies separated by processed, unprocessed, ignored and failed.

Remarks

Count options before Redis v7.2 works as expected with any quantity of entries on processed/unprocessed dependencies, since v7.2 you must consider that count won't have any effect until processed/unprocessed dependencies have a length greater than 127

See
getDependenciesCount()
getDependenciesCount(opts?): Promise<{
failed?: number;
ignored?: number;
processed?: number;
unprocessed?: number;
}>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:418

Get children job counts if this job is a parent and has children.

Parameters
opts?
failed?

boolean

ignored?

boolean

processed?

boolean

unprocessed?

boolean

Returns

Promise<{ failed?: number; ignored?: number; processed?: number; unprocessed?: number; }>

dependencies count separated by processed, unprocessed, ignored and failed.

getFailedChildrenValues()
getFailedChildrenValues(): Promise<{
[jobKey: string]: string;
}>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:389

Get job's children failure values that were ignored if any.

Returns

Promise<{ [jobKey: string]: string; }>

Object mapping children job keys with their failure values.

Deprecated

This method is deprecated and will be removed in v6. Use getIgnoredChildrenFailures instead.

getIgnoredChildrenFailures()
getIgnoredChildrenFailures(): Promise<{
[jobKey: string]: string;
}>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:379

Retrieves the failures of child jobs that were explicitly ignored while using ignoreDependencyOnFailure option. This method is useful for inspecting which child jobs were intentionally ignored when an error occured.

Returns

Promise<{ [jobKey: string]: string; }>

Object mapping children job keys with their failure values.

See

https://docs.bullmq.io/guide/flows/ignore-dependency

getState()
getState(): Promise<JobState | "unknown">;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:338

Get current state.

Returns

Promise<JobState | "unknown">

Returns one of these values: 'completed', 'failed', 'delayed', 'active', 'waiting', 'waiting-children', 'unknown'.

isActive()
isActive(): Promise<boolean>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:319

Returns

Promise<boolean>

true of the job is active.

isCompleted()
isCompleted(): Promise<boolean>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:303

Returns

Promise<boolean>

true if the job has completed.

isDelayed()
isDelayed(): Promise<boolean>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:311

Returns

Promise<boolean>

true if the job is delayed.

isFailed()
isFailed(): Promise<boolean>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:307

Returns

Promise<boolean>

true if the job has failed.

isWaiting()
isWaiting(): Promise<boolean>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:323

Returns

Promise<boolean>

true if the job is waiting.

isWaitingChildren()
isWaitingChildren(): Promise<boolean>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:315

Returns

Promise<boolean>

true if the job is waiting for children.

log()
log(logRow): Promise<number>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:233

Logs one row of log data.

Parameters
logRow

string

string with log data to be logged.

Returns

Promise<number>

The total number of log entries for this job so far.

Implementation of
MinimalJob.log
moveToCompleted()
moveToCompleted(
returnValue,
token,
fetchNext?): Promise<void | any[]>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:281

Moves a job to the completed queue. Returned job to be used with Queue.prototype.nextJobFromJobData.

Parameters
returnValue

ReturnType

The jobs success message.

token

string

Worker token used to acquire completed job.

fetchNext?

boolean

True when wanting to fetch the next job.

Returns

Promise<void | any[]>

Returns the jobData of the next job in the waiting queue or void.

moveToDelayed()
moveToDelayed(timestamp, token?): Promise<void>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:444

Moves the job to the delay set.

Parameters
timestamp

number

timestamp when the job should be moved back to "wait"

token?

string

token to check job is locked by current worker

Returns

Promise<void>

moveToFailed()
moveToFailed<E>(
err,
token,
fetchNext?): Promise<void | any[]>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:298

Moves a job to the failed queue.

Type Parameters
E

E extends Error

Parameters
err

E

the jobs error message.

token

string

token to check job is locked by current worker

fetchNext?

boolean

true when wanting to fetch the next job

Returns

Promise<void | any[]>

Returns the jobData of the next job in the waiting queue or void.

moveToWait()
moveToWait(token?): Promise<number>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:288

Moves a job to the wait or prioritized state.

Parameters
token?

string

Worker token used to acquire completed job.

Returns

Promise<number>

Returns pttl.

moveToWaitingChildren()
moveToWaitingChildren(token, opts?): Promise<boolean>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:452

Moves the job to the waiting-children set.

Parameters
token

string

Token to check job is locked by current worker

opts?

MoveToWaitingChildrenOpts

The options bag for moving a job to waiting-children.

Returns

Promise<boolean>

true if the job was moved

promote()
promote(): Promise<void>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:456

Promotes a delayed job so that it starts to be processed as soon as possible.

Returns

Promise<void>

remove()
remove(opts?): Promise<void>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:253

Completely remove the job from the queue. Note, this call will throw an exception if the job is being processed when the call is performed.

Parameters
opts?

Options to remove a job

removeChildren?

boolean

Returns

Promise<void>

removeChildDependency()
removeChildDependency(): Promise<boolean>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:239

Removes child dependency from parent when child is not yet finished

Returns

Promise<boolean>

True if the relationship existed and if it was removed.

removeDeduplicationKey()
removeDeduplicationKey(): Promise<boolean>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:486

Removes a deduplication key if job is still the cause of deduplication.

Returns

Promise<boolean>

true if the deduplication key was removed.

removeUnprocessedChildren()
removeUnprocessedChildren(): Promise<void>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:264

Remove all children from this job that are not yet processed, in other words that are in any other state than completed, failed or active.

Returns

Promise<void>

Remarks
  • Jobs with locks (most likely active) are ignored.
  • This method can be slow if the number of children is large (\> 1000).
retry()
retry(state?, opts?): Promise<void>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:466

Attempts to retry the job. Only a job that has failed or completed can be retried.

Parameters
state?

FinishedStatus

completed / failed

opts?

RetryOptions

options to retry a job

Returns

Promise<void>

A promise that resolves when the job has been successfully moved to the wait queue. The queue emits a waiting event when the job is successfully moved.

Throws

Will throw an error if the job does not exist, is locked, or is not in the expected state.

toJSON()
toJSON(): Omit<this, 
| "queue"
| "scripts"
| "toJSON"
| "asJSON"
| "asJSONSandbox"
| "updateData"
| "updateProgress"
| "log"
| "removeChildDependency"
| "clearLogs"
| "remove"
| "removeUnprocessedChildren"
| "extendLock"
| "moveToCompleted"
| "moveToWait"
| "moveToFailed"
| "isCompleted"
| "isFailed"
| "isDelayed"
| "isWaitingChildren"
| "isActive"
| "isWaiting"
| "queueName"
| "prefix"
| "getState"
| "changeDelay"
| "changePriority"
| "getChildrenValues"
| "getIgnoredChildrenFailures"
| "getFailedChildrenValues"
| "getDependencies"
| "getDependenciesCount"
| "waitUntilFinished"
| "moveToDelayed"
| "moveToWaitingChildren"
| "promote"
| "retry"
| "discard"
| "addJob"
| "removeDeduplicationKey">;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:203

Returns

Omit<this, | "queue" | "scripts" | "toJSON" | "asJSON" | "asJSONSandbox" | "updateData" | "updateProgress" | "log" | "removeChildDependency" | "clearLogs" | "remove" | "removeUnprocessedChildren" | "extendLock" | "moveToCompleted" | "moveToWait" | "moveToFailed" | "isCompleted" | "isFailed" | "isDelayed" | "isWaitingChildren" | "isActive" | "isWaiting" | "queueName" | "prefix" | "getState" | "changeDelay" | "changePriority" | "getChildrenValues" | "getIgnoredChildrenFailures" | "getFailedChildrenValues" | "getDependencies" | "getDependenciesCount" | "waitUntilFinished" | "moveToDelayed" | "moveToWaitingChildren" | "promote" | "retry" | "discard" | "addJob" | "removeDeduplicationKey">

updateData()
updateData(data): Promise<void>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:220

Updates a job's data

Parameters
data

DataType

the data that will replace the current jobs data.

Returns

Promise<void>

Implementation of
MinimalJob.updateData
updateProgress()
updateProgress(progress): Promise<void>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:226

Updates a job's progress

Parameters
progress

JobProgress

number or object to be saved as progress.

Returns

Promise<void>

Implementation of
MinimalJob.updateProgress
updateStacktrace()
protected updateStacktrace(err): void;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:488

Parameters
err

Error

Returns

void

validateOptions()
protected validateOptions(jobData): void;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:487

Parameters
jobData

JobJson

Returns

void

waitUntilFinished()
waitUntilFinished(queueEvents, ttl?): Promise<ReturnType>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:436

Returns a promise the resolves when the job has completed (containing the return value of the job), or rejects when the job has failed (containing the failedReason).

Parameters
queueEvents

QueueEvents

Instance of QueueEvents.

ttl?

number

Time in milliseconds to wait for job to finish before timing out.

Returns

Promise<ReturnType>

addJobLog()
static addJobLog(
queue,
jobId,
logRow,
keepLogs?): Promise<number>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:202

addJobLog

Parameters
queue

MinimalQueue

A minimal queue instance

jobId

string

Job id

logRow

string

String with a row of log data to be logged

keepLogs?

number

The optional amount of log entries to preserve

Returns

Promise<number>

The total number of log entries for this job so far.

create()
static create<T, R, N>(
queue,
name,
data,
opts?): Promise<Job<T, R, N>>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:160

Creates a new job and adds it to the queue.

Type Parameters
T

T = any

R

R = any

N

N extends string = string

Parameters
queue

MinimalQueue

the queue where to add the job.

name

N

the name of the job.

data

T

the payload of the job.

opts?

JobsOptions

the options bag for this job.

Returns

Promise<Job<T, R, N>>

createBulk()
static createBulk<T, R, N>(queue, jobs): Promise<Job<T, R, N>[]>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:168

Creates a bulk of jobs and adds them atomically to the given queue.

Type Parameters
T

T = any

R

R = any

N

N extends string = string

Parameters
queue

MinimalQueue

the queue were to add the jobs.

jobs

object[]

an array of jobs to be added to the queue.

Returns

Promise<Job<T, R, N>[]>

fromId()
static fromId<T, R, N>(queue, jobId): Promise<Job<T, R, N>>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:191

Fetches a Job from the queue given the passed job id.

Type Parameters
T

T = any

R

R = any

N

N extends string = string

Parameters
queue

MinimalQueue

the queue where the job belongs to.

jobId

string

the job id.

Returns

Promise<Job<T, R, N>>

fromJSON()
static fromJSON<T, R, N>(
queue,
json,
jobId?): Job<T, R, N>;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:181

Instantiates a Job from a JobJsonRaw object (coming from a deserialized JSON object)

Type Parameters
T

T = any

R

R = any

N

N extends string = string

Parameters
queue

MinimalQueue

the queue where the job belongs to.

json

JobJsonRaw

the plain object containing the job.

jobId?

string

an optional job id (overrides the id coming from the JSON object)

Returns

Job<T, R, N>

optsAsJSON()
static optsAsJSON(opts?, optsEncode?): RedisJobOptions;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:209

Parameters
opts?

JobsOptions

optsEncode?

Record<string, string>

Returns

RedisJobOptions

optsFromJSON()
static optsFromJSON(rawOpts?, optsDecode?): JobsOptions;

Defined in: node_modules/.pnpm/bullmq@5.66.5/node_modules/bullmq/dist/esm/classes/job.d.ts:183

Parameters
rawOpts?

string

optsDecode?

Record<string, string>

Returns

JobsOptions


QueueClient

Defined in: packages/core/src/core/queue/QueueClient.ts:20

QueueClient - Wrapper for BullMQ Queue (Producer side) Used by API Service to add jobs to queues

This class abstracts BullMQ implementation details. No direct BullMQ calls should be made outside this wrapper.

Implements

Constructors

Constructor
new QueueClient(redisConfig): QueueClient;

Defined in: packages/core/src/core/queue/QueueClient.ts:24

Parameters
redisConfig

RedisConfig

Returns

QueueClient

Methods

addBulk()
addBulk<T>(queueName, jobs): Promise<string[]>;

Defined in: packages/core/src/core/queue/QueueClient.ts:71

Add multiple jobs to a queue in bulk

Type Parameters
T

T

Parameters
queueName

string

jobs

JobData<T>[]

Returns

Promise<string[]>

Implementation of

IQueueClient.addBulk

addJob()
addJob<T>(
queueName,
jobName,
data,
options?): Promise<string>;

Defined in: packages/core/src/core/queue/QueueClient.ts:49

Add a single job to a queue

Type Parameters
T

T

Parameters
queueName

string

jobName

string

data

T

options?

JobOptions

Returns

Promise<string>

Implementation of

IQueueClient.addJob

close()
close(): Promise<void>;

Defined in: packages/core/src/core/queue/QueueClient.ts:146

Close all queue connections

Returns

Promise<void>

Implementation of

IQueueClient.close

getJobStatus()
getJobStatus(queueName, jobId): Promise<JobStatus>;

Defined in: packages/core/src/core/queue/QueueClient.ts:95

Get the status of a specific job

Parameters
queueName

string

jobId

string

Returns

Promise<JobStatus>

Implementation of

IQueueClient.getJobStatus

getQueueStatus()
getQueueStatus(queueName): Promise<QueueStatus>;

Defined in: packages/core/src/core/queue/QueueClient.ts:121

Get queue statistics

Parameters
queueName

string

Returns

Promise<QueueStatus>

Implementation of

IQueueClient.getQueueStatus


QueueManager

Defined in: packages/core/src/core/queue/QueueManager.ts:34

QueueManager - Wrapper for BullMQ Worker (Consumer side) Used by Worker Service to process jobs from queues

This class abstracts BullMQ implementation details. No direct BullMQ calls should be made outside this wrapper.

Constructors

Constructor
new QueueManager(redisConfig): QueueManager;

Defined in: packages/core/src/core/queue/QueueManager.ts:40

Parameters
redisConfig

RedisConfig

Returns

QueueManager

Methods

cleanQueue()
cleanQueue(
queueName,
grace?,
status?): Promise<void>;

Defined in: packages/core/src/core/queue/QueueManager.ts:306

Clean completed/failed jobs from a queue

Parameters
queueName

string

grace?

number = 0

status?

"completed" | "failed"

Returns

Promise<void>

close()
close(): Promise<void>;

Defined in: packages/core/src/core/queue/QueueManager.ts:318

Close all workers and connections

Returns

Promise<void>

getQueueStatus()
getQueueStatus(queueName): Promise<QueueStatus>;

Defined in: packages/core/src/core/queue/QueueManager.ts:248

Get queue status/statistics

Parameters
queueName

string

Returns

Promise<QueueStatus>

getWorkersStatus()
getWorkersStatus(): object[];

Defined in: packages/core/src/core/queue/QueueManager.ts:273

Get status of all registered workers

Returns

object[]

pauseQueue()
pauseQueue(queueName): Promise<void>;

Defined in: packages/core/src/core/queue/QueueManager.ts:290

Pause a queue (stops new jobs from being processed)

Parameters
queueName

string

Returns

Promise<void>

register()
register(workerClass): void;

Defined in: packages/core/src/core/queue/QueueManager.ts:72

Register a worker class decorated with

Parameters
workerClass

QueueWorkerConstructor

Returns

void

Queue Worker
resumeQueue()
resumeQueue(queueName): Promise<void>;

Defined in: packages/core/src/core/queue/QueueManager.ts:298

Resume a paused queue

Parameters
queueName

string

Returns

Promise<void>

setContainer()
setContainer(container): void;

Defined in: packages/core/src/core/queue/QueueManager.ts:47

Set the Inversify container for dependency injection

Parameters
container

Container

Returns

void

start()
start(queueName): void;

Defined in: packages/core/src/core/queue/QueueManager.ts:218

Start a specific worker by queue name

Parameters
queueName

string

Returns

void

startAll()
startAll(): void;

Defined in: packages/core/src/core/queue/QueueManager.ts:192

Start all registered workers

Returns

void

stop()
stop(queueName): Promise<void>;

Defined in: packages/core/src/core/queue/QueueManager.ts:233

Stop a specific worker by queue name

Parameters
queueName

string

Returns

Promise<void>

stopAll()
stopAll(): Promise<void>;

Defined in: packages/core/src/core/queue/QueueManager.ts:205

Stop all registered workers

Returns

Promise<void>

Interfaces

IQueueClient

Defined in: packages/core/src/core/queue/types.ts:134

Interface for Queue Client (used by API Service). Only responsible for adding jobs to queues - never consumes.

Methods

addBulk()
addBulk<T>(queueName, jobs): Promise<string[]>;

Defined in: packages/core/src/core/queue/types.ts:156

Add multiple jobs to a queue in bulk

Type Parameters
T

T

Parameters
queueName

string

Name of the queue

jobs

JobData<T>[]

Array of job data

Returns

Promise<string[]>

Array of Job IDs

addJob()
addJob<T>(
queueName,
jobName,
data,
options?): Promise<string>;

Defined in: packages/core/src/core/queue/types.ts:143

Add a single job to a queue

Type Parameters
T

T

Parameters
queueName

string

Name of the queue

jobName

string

Name/type of the job

data

T

Job payload data

options?

JobOptions

Optional job configuration

Returns

Promise<string>

Job ID

close()
close(): Promise<void>;

Defined in: packages/core/src/core/queue/types.ts:174

Close all connections

Returns

Promise<void>

getJobStatus()
getJobStatus(queueName, jobId): Promise<JobStatus>;

Defined in: packages/core/src/core/queue/types.ts:163

Get the status of a specific job

Parameters
queueName

string

Name of the queue

jobId

string

Job ID

Returns

Promise<JobStatus>

getQueueStatus()
getQueueStatus(queueName): Promise<QueueStatus>;

Defined in: packages/core/src/core/queue/types.ts:169

Get queue statistics

Parameters
queueName

string

Name of the queue

Returns

Promise<QueueStatus>


IQueueWorkerHandler

Defined in: packages/core/src/core/queue/types.ts:101

Interface for queue worker handlers

Type Parameters

T

T = any

Methods

onCompleted()?
optional onCompleted(job, result): void;

Defined in: packages/core/src/core/queue/types.ts:110

Called when a job completes successfully

Parameters
job

Job<T>

result

any

Returns

void

onFailed()?
optional onFailed(job, error): void;

Defined in: packages/core/src/core/queue/types.ts:115

Called when a job fails

Parameters
job

Job<T>

error

Error

Returns

void

onProgress()?
optional onProgress(job, progress): void;

Defined in: packages/core/src/core/queue/types.ts:120

Called when job progress is updated

Parameters
job

Job<T>

progress

number | object

Returns

void

process()
process(job): Promise<any>;

Defined in: packages/core/src/core/queue/types.ts:105

Process a job from the queue

Parameters
job

Job<T>

Returns

Promise<any>


JobData

Defined in: packages/core/src/core/queue/types.ts:44

Job data structure

Type Parameters

T

T = any

Properties

data
data: T;

Defined in: packages/core/src/core/queue/types.ts:46

name
name: string;

Defined in: packages/core/src/core/queue/types.ts:45

options?
optional options: JobOptions;

Defined in: packages/core/src/core/queue/types.ts:47


JobOptions

Defined in: packages/core/src/core/queue/types.ts:21

Options for adding a job to a queue

Properties

attempts?
optional attempts: number;

Defined in: packages/core/src/core/queue/types.ts:25

Number of retry attempts on failure

backoff?
optional backoff: object;

Defined in: packages/core/src/core/queue/types.ts:27

Backoff strategy for retries

delay
delay: number;
type
type: "fixed" | "exponential";
delay?
optional delay: number;

Defined in: packages/core/src/core/queue/types.ts:23

Delay before the job is processed (ms)

jobId?
optional jobId: string;

Defined in: packages/core/src/core/queue/types.ts:38

Unique job ID (prevents duplicates)

priority?
optional priority: number;

Defined in: packages/core/src/core/queue/types.ts:32

Job priority (lower = higher priority)

removeOnComplete?
optional removeOnComplete: number | boolean;

Defined in: packages/core/src/core/queue/types.ts:34

Remove job from queue after completion

removeOnFail?
optional removeOnFail: number | boolean;

Defined in: packages/core/src/core/queue/types.ts:36

Remove job from queue after failure


JobStatus

Defined in: packages/core/src/core/queue/types.ts:53

Job status information

Properties

attemptsMade
attemptsMade: number;

Defined in: packages/core/src/core/queue/types.ts:61

data
data: any;

Defined in: packages/core/src/core/queue/types.ts:58

failedReason?
optional failedReason: string;

Defined in: packages/core/src/core/queue/types.ts:60

id
id: string;

Defined in: packages/core/src/core/queue/types.ts:54

name
name: string;

Defined in: packages/core/src/core/queue/types.ts:55

progress
progress: number;

Defined in: packages/core/src/core/queue/types.ts:57

returnValue?
optional returnValue: any;

Defined in: packages/core/src/core/queue/types.ts:59

status
status: "waiting" | "active" | "completed" | "failed" | "delayed";

Defined in: packages/core/src/core/queue/types.ts:56

timestamp
timestamp: number;

Defined in: packages/core/src/core/queue/types.ts:62


QueueStatus

Defined in: packages/core/src/core/queue/types.ts:68

Queue status information

Properties

active
active: number;

Defined in: packages/core/src/core/queue/types.ts:71

completed
completed: number;

Defined in: packages/core/src/core/queue/types.ts:72

delayed
delayed: number;

Defined in: packages/core/src/core/queue/types.ts:74

failed
failed: number;

Defined in: packages/core/src/core/queue/types.ts:73

name
name: string;

Defined in: packages/core/src/core/queue/types.ts:69

paused
paused: boolean;

Defined in: packages/core/src/core/queue/types.ts:75

waiting
waiting: number;

Defined in: packages/core/src/core/queue/types.ts:70


QueueWorkerMetadata

Defined in: packages/core/src/core/queue/types.ts:93

Metadata for

Queue Worker

decorator

Properties

options
options: WorkerOptions;

Defined in: packages/core/src/core/queue/types.ts:95

queueName
queueName: string;

Defined in: packages/core/src/core/queue/types.ts:94


RedisConfig

Defined in: packages/core/src/core/queue/types.ts:6

Redis connection configuration

Properties

db?
optional db: number;

Defined in: packages/core/src/core/queue/types.ts:10

host
host: string;

Defined in: packages/core/src/core/queue/types.ts:7

password?
optional password: string;

Defined in: packages/core/src/core/queue/types.ts:9

port
port: number;

Defined in: packages/core/src/core/queue/types.ts:8


WorkerOptions

Defined in: packages/core/src/core/queue/types.ts:81

Worker configuration options

Properties

concurrency?
optional concurrency: number;

Defined in: packages/core/src/core/queue/types.ts:83

Number of concurrent jobs to process

lockDuration?
optional lockDuration: number;

Defined in: packages/core/src/core/queue/types.ts:85

Lock duration for a job (ms)

maxStalledCount?
optional maxStalledCount: number;

Defined in: packages/core/src/core/queue/types.ts:87

Maximum stalled count before failing

Type Aliases

QueueWorkerConstructor()

type QueueWorkerConstructor = (...args) => IQueueWorkerHandler;

Defined in: packages/core/src/core/queue/types.ts:126

Constructor type for queue worker classes

Parameters

args

...any[]

Returns

IQueueWorkerHandler

References

QUEUE_WORKER_METADATA_KEY

Re-exports QUEUE_WORKER_METADATA_KEY


QueueWorker

Re-exports QueueWorker