Job Management
Monque serves a comprehensive set of APIs for managing jobs throughout their lifecycle.
Quick Reference
Section titled “Quick Reference”| Method | Description |
|---|---|
cancelJob() | Cancel a single job |
retryJob() | Retry a job |
rescheduleJob() | Reschedule a job |
deleteJob() | Delete a job |
cancelJobs() | Bulk cancel |
retryJobs() | Bulk retry |
deleteJobs() | Bulk delete |
getJobsWithCursor() | Paginated list |
getQueueStats() | Queue statistics |
Single Job Operations
Section titled “Single Job Operations”Manage individual jobs using their unique ID.
Cancel a Job
Section titled “Cancel a Job”Use cancelJob() to prevent a pending or scheduled job from running.
- Effect: Status becomes
cancelled. - Event: Emits
job:cancelled. - Constraint: Cannot cancel
processing,completed, orfailedjobs (unless they return to pending).
Retry a Job
Section titled “Retry a Job”Use retryJob() to retry a failed or cancelled job immediately.
- Effect: Status becomes
pending,nextRunAtset to now, failure count reset. - Event: Emits
job:retried.
Reschedule a Job
Section titled “Reschedule a Job”Use rescheduleJob() to change the execution time of a pending job.
Delete a Job
Section titled “Delete a Job”Use deleteJob() to permanently remove a job from the queue.
- Effect: Document is removed from MongoDB.
- Event: Emits
job:deleted.
Bulk Operations
Section titled “Bulk Operations”Perform operations on multiple jobs matching a filter.
Bulk Cancel
Section titled “Bulk Cancel”Use cancelJobs() to cancel all pending jobs matching a criteria.
Bulk Retry
Section titled “Bulk Retry”Use retryJobs() to retry all failed jobs.
Bulk Delete
Section titled “Bulk Delete”Use deleteJobs() to clean up old jobs.
- Effect: Removing matching documents from MongoDB.
- Event: Emits
jobs:deletedwith count.
Pagination
Section titled “Pagination”Efficiently iterate through large sets of jobs using getJobsWithCursor().
Supports filtering:
Queue Statistics
Section titled “Queue Statistics”Get real-time insights into your queue health using getQueueStats().
You can also scope statistics to a specific job name: