Kue: Fail a job

Created on 21 Mar 2013  路  3Comments  路  Source: Automattic/kue

I'm building an application which runs Kue after a file has changed, it triggers a set of jobs and all is good. However I want to be able to purposefully fail a job if something goes wrong.

For example, I request a web page, but if the http.statusCode !== 200 the job should fail and no other job should be processed.

How do I go about that?

Most helpful comment

You can fail a job via

var kue = require('kue')
   , jobs = kue.createQueue();

jobs.process('email', function(job, done) {
    var err = new Error('purposely fail job');
    job.failed().error(err);
    done(err);
});

@drudge please close

All 3 comments

You can fail a job via

var kue = require('kue')
   , jobs = kue.createQueue();

jobs.process('email', function(job, done) {
    var err = new Error('purposely fail job');
    job.failed().error(err);
    done(err);
});

@drudge please close

This doesn't work.

kue.Job.get(job_id, function (err, job) {
    var err = new Error('purposely fail job');
    job.failed().error(err);
});

The normal way to fail a job is by calling done @knutole , So you should keep a reference to it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danpalmer picture danpalmer  路  8Comments

robert-irribarren picture robert-irribarren  路  3Comments

adriano-di-giovanni picture adriano-di-giovanni  路  9Comments

digitaljohn picture digitaljohn  路  10Comments

alexbudin picture alexbudin  路  5Comments