-
Notifications
You must be signed in to change notification settings - Fork 16
Job Status
During the life cycle of a job it can have its status changed a number of times. This document will give you a better understanding of the job status values and when they get assigned.
Status | Description |
---|---|
created | After creating the job |
waiting | After being added to the queue |
active | Whilst the job is being processed |
completed | When the job has been processed successfully |
cancelled | If you cancel a job |
failed | When the job has failed being processed |
terminated | When a job has failed and will not be retried |
Before you can process jobs with the Queue object you need to create jobs. Jobs get created by calling the Queue.createJob method. A newly created job will have a status of created
and does not exist in the queue database table. The created
status is used to prevent invalid queue function calls prior to the job being added to the queue.
Once you have added data to your new job, add it to the queue using Queue.addJob. After the job is added to the queue the created
job status will no longer be assigned to this job.
After calling Queue.addJob the job status in the database will be set to waiting
. A job should not stay at this status for long because it is ready for processing. As soon as a Queue object with a Queue.process handler function is available to process the job it will get assigned the active
status.
Once a job gets picked up for processing the waiting
status will no longer be assigned to this job.
A job gets a status of active
when it is picked up by a Queue object enabled for processing jobs. If you do not add a job handling function to your Queue objects using Queue.process they will never process jobs.
Job processing begins once a Queue object has a job handling function assigned. The Queue object will query the queue database for the next pool of jobs and they will all be assigned an active
status. The number of jobs getting processed and marked with the active
status depends on the concurrency
Queue option.
The active
job status can be assigned to a job a number of times if it fails processing and is available for retry. See the Job Retry document for more detail.
On the successful completion of job processing, jobs will be updated to have a completed
status. This is the desired state of all jobs added to the queue. Depending on the removeFinishedJobs
Queue option a completed
job may be removed from the queue database table.
The completed
job status is the end game for any job. Not all jobs will make it this far.
A job can get cancelled by one of two processes;
- Using the Queue.cancelJob method.
- Passing an
error
object into the Queue.processnext()
callback with theerror.cancelJob
property set.
For whatever reason you want to cancel the job, using one of the above methods will set the job status to cancelled. The job will no longer get processed by the queue and is now dead.
See the Cancel Job document for more detail.
Depending on the retryMax
Job option, a job may get assigned the failed
status. This is not all that bad, it means the job still has a life left. See the Job Retry document for more detail.
A failed
job can be made active again up to the retryMax
number of times. Once this happens it only has two places to go; completed
(yay!), or terminated
(it will not be back).
A job is set to a status of terminated
if it fails processing for some reason and has either retryMax
set to zero or the retryCount
has hit the retryMax
value. See the Job Options document for more detail.
This is a bad status for a job to get. It was never successfully processed and is no longer going to get processed.
The terminated
status for a job indicates the job has chosen the wrong path in its life and it has come to the ultimate end.
- Introduction
- Tutorial
- Queue Constructor
- Queue Connection
- Queue Options
- Queue PubSub
- Queue Master
- Queue Events
- State Document
- Job Processing
- Job Options
- Job Status
- Job Retry
- Job Repeat
- Job Logging
- Job Editing
- Job Schema
- Job Name
- Complex Job
- Delayed Job
- Cancel Job
- Error Handling
- Queue.createJob
- Queue.addJob
- Queue.getJob
- Queue.findJob
- Queue.findJobByName
- Queue.containsJobByName
- Queue.cancelJob
- Queue.reanimateJob
- Queue.removeJob
- Queue.process
- Queue.review
- Queue.summary
- Queue.ready
- Queue.pause
- Queue.resume
- Queue.reset
- Queue.stop
- Queue.drop
- Queue.Job
- Queue.host
- Queue.port
- Queue.db
- Queue.name
- Queue.r
- Queue.id
- Queue.jobOptions [R/W]
- Queue.changeFeed
- Queue.master
- Queue.masterInterval
- Queue.removeFinishedJobs
- Queue.running
- Queue.concurrency [R/W]
- Queue.paused
- Queue.idle
- Event.ready
- Event.added
- Event.updated
- Event.active
- Event.processing
- Event.progress
- Event.log
- Event.pausing
- Event.paused
- Event.resumed
- Event.completed
- Event.cancelled
- Event.failed
- Event.terminated
- Event.reanimated
- Event.removed
- Event.idle
- Event.reset
- Event.error
- Event.reviewed
- Event.detached
- Event.stopping
- Event.stopped
- Event.dropped
- Job.setName
- Job.setPriority
- Job.setTimeout
- Job.setDateEnable
- Job.setRetryMax
- Job.setRetryDelay
- Job.setRepeat
- Job.setRepeatDelay
- Job.updateProgress
- Job.update
- Job.getCleanCopy
- Job.addLog
- Job.getLastLog