Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability not to start job after delay #1055

Closed
niko-lay opened this issue Sep 19, 2018 · 5 comments
Closed

Ability not to start job after delay #1055

niko-lay opened this issue Sep 19, 2018 · 5 comments

Comments

@niko-lay
Copy link

Hello
I'm looking for feature to not start job processing if some delay elapsed time since the addition to queue. I assumed that parameter Job#delay is designed for this porposes, but it does not seem like this.

Here is minimal example

const Queue = require('bull');
const m = require('moment');
const conf = require('./lib/config.js');


const JOB_PROCESS_TIME = 15 * 1000; // simulate long job
const JOB_T = 3* 1000;
const JOB_D = 1 * 1000;

// process 1 job per 30 sec
var testQ = new Queue('testQ', {limiter: {max: 1, duration: 30 * 1000}, redis: conf.redisConnection });
testQ.empty()
    .then(()=>{
        console.log('testQ is empty now');

        for (i = 0; i< 3; i++){
            testQ.add({data: 'test-test-test', dateStrAdded: m().format(), date: new m()},
                      {delay: JOB_D, timeout: JOB_T})
                    .then((job)=>{
                        console.log('job added: ' + job.id);
                    })
                    .catch(console.error);
        }
    });

testQ.process(function(job, done){
    console.log(`Request job process: ${job.id} ${m().format()}`);
    setTimeout(()=>{
        var diff = m() - m(job.data.date);
        console.log("job processed : " + job.id + ' ' + m().format() + ' diff: '  + diff);

        done(null, {data: 'someData'})
    }, JOB_PROCESS_TIME);
})


testQ
.on('completed', function(job, result){
    //console.log("completed: " + job.id + ' ' + JSON.stringify(result));
    console.log("completed: " + JSON.stringify(job));
})
.on('failed', function(job, err){
    var diff = m() - m(job.data.date);
    console.log("failed: " + job.id + ' ' + m().format() + ' diff: '  + diff);

})

and output

testQ is empty now
job added: 19
job added: 20
job added: 21 <<<<<<<<<<< all added at once
Request job process: 19 2018-09-19T17:33:40+04:00
failed: 19 2018-09-19T17:33:45+04:00 diff: 6792 <<<<<<<<<<< now I would like all jobs failed, but only the first did it
job processed : 19 2018-09-19T17:33:55+04:00 diff: 16463
Request job process: 20 2018-09-19T17:34:10+04:00
failed: 20 2018-09-19T17:34:15+04:00 diff: 36952
job processed : 20 2018-09-19T17:34:25+04:00 diff: 46627
Request job process: 21 2018-09-19T17:34:40+04:00
failed: 21 2018-09-19T17:34:45+04:00 diff: 67115
job processed : 21 2018-09-19T17:34:55+04:00 diff: 76790

bull version v.3.4.8

Any ability to not start/remove/fail job after a certain time after its addition, not start processing?

@manast
Copy link
Member

manast commented Sep 19, 2018

you will need to rephrase what are your expected behaviour, since I am not able to comprehend it based on your description.

@niko-lay
Copy link
Author

I need something like TTL for single job or for all queue.

@manast
Copy link
Member

manast commented Sep 19, 2018

Something like this? #479

@niko-lay
Copy link
Author

yes. I seems this not yet implemented in bull?

@manast
Copy link
Member

manast commented Sep 19, 2018

The issue is still open so no. I will close then this one as a duplicated.

@manast manast closed this as completed Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants