-
Notifications
You must be signed in to change notification settings - Fork 16
Queue.createJob
Grant Carthew edited this page Jul 28, 2016
·
27 revisions
To add jobs to the queue you need to have the basic structure of a job required for rethinkdb-job-queue to be able to work with the data.
You use the Queue.createJob() method to get the produce a job object that looks like the following:
{
q: [object Object], // This is a reference to the Queue that created the job
id: '07290a09-269b-4211-9698-ea40f69962b2', // This will be the jobs id in the database
priority: 'normal',
timeout: 300,
retryDelay: 600,
retryMax: 3,
retryCount: 0,
progress: 0,
status: 'created',
log: [],
dateCreated: 2016-07-27T22:54:45.811Z,
dateRetry: 2016-07-27T22:54:45.811Z,
queueId: 'WebDev:rjqJobQueue:rjqJobList:11761:89c2d49e-5a04-4d9b-b08e-48908625ea64'
}You will notice there are no properties to hold your job data. You can decorate the job object with any property you like. There is a Job.setPayload method you can call to add a Job.payload property however there is no difference to calling that method or simply doing Job.payload = <some data>.
So once you have this job object you can feel free to add properties to it anyway you like. For example:
const Queue = require('rethinkdb-job-queue')
const q = new Queue()
const job = q.createJob()
job.recipient = '[email protected]'
job.subject = 'Registration for superheros.com'
job.body = 'Click this link to activate your account on superheros.com'
q.addJob(job).then((savedJobs) => {
// savedJobs is a valid job object with updated properties
}).catch((err) => {
console.error(err)
})- 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