Skip to main content

JobQueueService

The JobQueueService is used to create new JobQueue instances and access existing jobs.

Example

Ts
Signature
  • Implements: OnModuleDestroy

constructor

method(configService: ConfigService, jobBufferService: JobBufferService) => JobQueueService

createQueue

method(options: CreateQueueOptions<Data>) => Promise<JobQueue<Data>>

Configures and creates a new JobQueue instance.

start

method() => Promise<void>

addBuffer

method(buffer: JobBuffer<any>) => v1.3.0

Adds a JobBuffer, which will make it active and begin collecting jobs to buffer.

removeBuffer

method(buffer: JobBuffer<any>) => v1.3.0

Removes a JobBuffer, prevent it from collecting and buffering any subsequent jobs.

bufferSize

method(forBuffers: Array<JobBuffer<any> | string>) => Promise<{ [bufferId: string]: number }>v1.3.0

Returns an object containing the number of buffered jobs arranged by bufferId. This can be used to decide whether a particular buffer has any jobs to flush.

Passing in JobBuffer instances or ids limits the results to the specified JobBuffers. If no argument is passed, sizes will be returned for all JobBuffers.

Example

Ts

flush

method(forBuffers: Array<JobBuffer<any> | string>) => Promise<Job[]>v1.3.0

Flushes the specified buffers, which means that the buffer is cleared and the jobs get sent to the job queue for processing. Before sending the jobs to the job queue, they will be passed through each JobBuffer's reduce() method, which is can be used to optimize the amount of work to be done by e.g. de-duplicating identical jobs or aggregating data over the collected jobs.

Passing in JobBuffer instances or ids limits the action to the specified JobBuffers. If no argument is passed, all JobBuffers will be flushed.

Returns an array of all Jobs which were added to the job queue.

getJobQueues

method() => GraphQlJobQueue[]

Returns an array of { name: string; running: boolean; } for each registered JobQueue.

Was this chapter helpful?
Report Issue
Edited Feb 25, 2026ยทEdit this page