Skip to main content

Overview

The QueueGetters class provides various getter methods for retrieving information about jobs, counts, and queue state. The Queue class extends QueueGetters, so all these methods are available on Queue instances.
You typically don’t instantiate QueueGetters directly. Use the Queue class which inherits these methods.

Methods

getJob

Fetches a job by its ID.
getJob(jobId: string): Promise<Job | undefined>
jobId
string
required
The job ID to fetch

count

Returns the number of jobs waiting to be processed.
count(): Promise<number>
count
number
Total count of waiting, paused, delayed, prioritized, and waiting-children jobs

getJobCounts

Returns the job counts for each type specified.
getJobCounts(...types: JobType[]): Promise<{ [index: string]: number }>
types
JobType[]
Job types to count (e.g., ‘waiting’, ‘active’, ‘completed’, ‘failed’)
const counts = await queue.getJobCounts('waiting', 'active', 'completed');
// { waiting: 5, active: 2, completed: 100 }

getJobCountByTypes

Returns the total count for specified job types.
getJobCountByTypes(...types: JobType[]): Promise<number>

getCompletedCount

Returns the number of jobs in completed status.
getCompletedCount(): Promise<number>

getFailedCount

Returns the number of jobs in failed status.
getFailedCount(): Promise<number>

getDelayedCount

Returns the number of jobs in delayed status.
getDelayedCount(): Promise<number>

getActiveCount

Returns the number of jobs in active status.
getActiveCount(): Promise<number>

getWaitingCount

Returns the number of jobs in waiting or paused status.
getWaitingCount(): Promise<number>

getWaitingChildrenCount

Returns the number of jobs in waiting-children status.
getWaitingChildrenCount(): Promise<number>

getPrioritizedCount

Returns the number of jobs in prioritized status.
getPrioritizedCount(): Promise<number>

getCountsPerPriority

Returns the number of jobs per priority level.
getCountsPerPriority(priorities: number[]): Promise<{ [index: string]: number }>
priorities
number[]
required
Array of priority values to check
const counts = await queue.getCountsPerPriority([0, 1, 2]);
// { '0': 10, '1': 5, '2': 3 }

getJobs

Returns jobs on the given statuses.
getJobs(
  types?: JobType[],
  start?: number,
  end?: number,
  asc?: boolean
): Promise<Job[]>
types
JobType[]
Job statuses to retrieve
start
number
default:"0"
Zero-based index from where to start
end
number
default:"-1"
Zero-based index where to stop
asc
boolean
default:"false"
If true, return in ascending order

getWaiting

Returns jobs in waiting status.
getWaiting(start?: number, end?: number): Promise<Job[]>

getWaitingChildren

Returns jobs in waiting-children status.
getWaitingChildren(start?: number, end?: number): Promise<Job[]>

getActive

Returns jobs in active status.
getActive(start?: number, end?: number): Promise<Job[]>

getDelayed

Returns jobs in delayed status.
getDelayed(start?: number, end?: number): Promise<Job[]>

getPrioritized

Returns jobs in prioritized status.
getPrioritized(start?: number, end?: number): Promise<Job[]>

getCompleted

Returns jobs in completed status.
getCompleted(start?: number, end?: number): Promise<Job[]>

getFailed

Returns jobs in failed status.
getFailed(start?: number, end?: number): Promise<Job[]>

getJobLogs

Returns the logs for a given job.
getJobLogs(
  jobId: string,
  start?: number,
  end?: number,
  asc?: boolean
): Promise<{ logs: string[]; count: number }>
jobId
string
required
The job ID to get logs for
start
number
default:"0"
Start index
end
number
default:"-1"
End index
asc
boolean
default:"true"
Return in ascending order

getJobState

Gets the current state of a job.
getJobState(jobId: string): Promise<JobState | 'unknown'>
state
string
One of: ‘completed’, ‘failed’, ‘delayed’, ‘active’, ‘waiting’, ‘waiting-children’, ‘unknown’

getDependencies

Returns the dependencies of a parent job.
getDependencies(
  parentId: string,
  type: 'processed' | 'pending',
  start: number,
  end: number
): Promise<{
  items: { id: string; v?: any; err?: string }[];
  jobs: JobJsonRaw[];
  total: number;
}>

getMeta

Returns the global queue configuration.
getMeta(): Promise<QueueMeta>

getGlobalConcurrency

Gets the global concurrency value.
getGlobalConcurrency(): Promise<number | null>

getGlobalRateLimit

Gets the global rate limit values.
getGlobalRateLimit(): Promise<{ max: number; duration: number } | null>

getRateLimitTtl

Returns the time to live for a rate limited key.
getRateLimitTtl(maxJobs?: number): Promise<number>
ttl
number
-2 if key does not exist, -1 if key exists but has no expire, otherwise TTL in milliseconds

getDeduplicationJobId

Gets the job ID from deduplicated state.
getDeduplicationJobId(id: string): Promise<string | null>
id
string
required
Deduplication identifier

getWorkers

Gets the worker list related to the queue.
getWorkers(): Promise<Array<{ [index: string]: string }>>

getWorkersCount

Returns the current count of workers for the queue.
getWorkersCount(): Promise<number>

getMetrics

Gets queue metrics.
getMetrics(
  type: 'completed' | 'failed',
  start?: number,
  end?: number
): Promise<Metrics>
type
string
required
Metric type: ‘completed’ or ‘failed’
start
number
default:"0"
Start point (0 is newest)
end
number
default:"-1"
End point (-1 is oldest)

exportPrometheusMetrics

Exports metrics in Prometheus format.
exportPrometheusMetrics(
  globalVariables?: Record<string, string>
): Promise<string>
globalVariables
Record<string, string>
Additional labels to include in metrics
const metrics = await queue.exportPrometheusMetrics({
  service: 'my-service',
  environment: 'production',
});

console.log(metrics);
// # HELP bullmq_job_count Number of jobs in the queue by state
// # TYPE bullmq_job_count gauge
// bullmq_job_count{queue="myQueue", state="waiting", service="my-service", environment="production"} 5

JobType

Valid job types/states:
  • 'active' - Currently being processed
  • 'waiting' - Waiting to be processed
  • 'completed' - Successfully completed
  • 'failed' - Failed after all attempts
  • 'delayed' - Scheduled for future processing
  • 'paused' - In a paused queue
  • 'prioritized' - Waiting with priority
  • 'waiting-children' - Waiting for child jobs to complete

Build docs developers (and LLMs) love