MonqueService
Defined in: tsed/src/services/monque-service.ts:45
Injectable service that wraps the Monque instance.
Exposes the full Monque public API through dependency injection.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”Returns
Section titled “Returns”MonqueService
Accessors
Section titled “Accessors”monque
Section titled “monque”Get Signature
Section titled “Get Signature”Defined in: tsed/src/services/monque-service.ts:65
Access the underlying Monque instance.
Throws
Section titled “Throws”Error if MonqueModule is not initialized
Returns
Section titled “Returns”Monque
Methods
Section titled “Methods”cancelJob()
Section titled “cancelJob()”Defined in: tsed/src/services/monque-service.ts:130
Cancel a pending or scheduled job.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
jobId | string | The ID of the job to cancel |
Returns
Section titled “Returns”Promise<PersistedJob<unknown> | null>
The cancelled job, or null if not found
cancelJobs()
Section titled “cancelJobs()”Defined in: tsed/src/services/monque-service.ts:175
Cancel multiple jobs matching the given filter.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
filter | JobSelector | Selector for which jobs to cancel |
Returns
Section titled “Returns”Promise<BulkOperationResult>
Result with count of cancelled jobs
deleteJob()
Section titled “deleteJob()”Defined in: tsed/src/services/monque-service.ts:161
Permanently delete a job.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
jobId | string | The ID of the job to delete |
Returns
Section titled “Returns”Promise<boolean>
true if deleted, false if job not found
deleteJobs()
Section titled “deleteJobs()”Defined in: tsed/src/services/monque-service.ts:195
Delete multiple jobs matching the given filter.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
filter | JobSelector | Selector for which jobs to delete |
Returns
Section titled “Returns”Promise<BulkOperationResult>
Result with count of deleted jobs
enqueue()
Section titled “enqueue()”Defined in: tsed/src/services/monque-service.ts:87
Enqueue a job for processing.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
name | string | Job type identifier (use full namespaced name, e.g., “email.send”) |
data | T | Job payload |
options? | EnqueueOptions | Scheduling and deduplication options |
Returns
Section titled “Returns”Promise<PersistedJob<T>>
The created or existing job document
getJob()
Section titled “getJob()”Defined in: tsed/src/services/monque-service.ts:210
Get a job by its ID.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
jobId | string | ObjectId | The job’s ObjectId (as string or ObjectId) |
Returns
Section titled “Returns”Promise<PersistedJob<T> | null>
The job document, or null if not found
Throws
Section titled “Throws”MonqueError if jobId is an invalid hex string
getJobs()
Section titled “getJobs()”Defined in: tsed/src/services/monque-service.ts:231
Query jobs from the queue with optional filters.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
filter? | GetJobsFilter | Optional filter criteria (name, status, limit, skip) |
Returns
Section titled “Returns”Promise<PersistedJob<T>[]>
Array of matching jobs
getJobsWithCursor()
Section titled “getJobsWithCursor()”Defined in: tsed/src/services/monque-service.ts:241
Get a paginated list of jobs using opaque cursors.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options? | CursorOptions | Pagination options (cursor, limit, direction, filter) |
Returns
Section titled “Returns”Promise<CursorPage<T>>
Page of jobs with next/prev cursors
getQueueStats()
Section titled “getQueueStats()”Defined in: tsed/src/services/monque-service.ts:251
Get aggregate statistics for the job queue.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
filter? | Pick<JobSelector, "name"> | Optional filter to scope statistics by job name |
Returns
Section titled “Returns”Promise<QueueStats>
Queue statistics
isHealthy()
Section titled “isHealthy()”Defined in: tsed/src/services/monque-service.ts:264
Check if the scheduler is healthy and running.
Returns
Section titled “Returns”boolean
true if running and connected
Defined in: tsed/src/services/monque-service.ts:98
Enqueue a job for immediate processing.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
name | string | Job type identifier |
data | T | Job payload |
Returns
Section titled “Returns”Promise<PersistedJob<T>>
The created job document
rescheduleJob()
Section titled “rescheduleJob()”Defined in: tsed/src/services/monque-service.ts:151
Reschedule a pending job to run at a different time.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
jobId | string | The ID of the job to reschedule |
runAt | Date | The new Date when the job should run |
Returns
Section titled “Returns”Promise<PersistedJob<unknown> | null>
The updated job, or null if not found
retryJob()
Section titled “retryJob()”Defined in: tsed/src/services/monque-service.ts:140
Retry a failed or cancelled job.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
jobId | string | The ID of the job to retry |
Returns
Section titled “Returns”Promise<PersistedJob<unknown> | null>
The updated job, or null if not found
retryJobs()
Section titled “retryJobs()”Defined in: tsed/src/services/monque-service.ts:185
Retry multiple jobs matching the given filter.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
filter | JobSelector | Selector for which jobs to retry |
Returns
Section titled “Returns”Promise<BulkOperationResult>
Result with count of retried jobs
schedule()
Section titled “schedule()”Defined in: tsed/src/services/monque-service.ts:111
Schedule a recurring job with a cron expression.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cron | string | Cron expression (5-field standard or predefined like @daily) |
name | string | Job type identifier |
data | T | Job payload |
options? | ScheduleOptions | Scheduling options |
Returns
Section titled “Returns”Promise<PersistedJob<T>>
The created job document