简体   繁体   中英

Get the iteration position in repeatable jobs in bulljs

I'd like to perform some actions in a certain position within the repeatable job callback for example

const Bull = require('bull');
const queue = new Bull('payment');

// should repeat this task every 5 minutes , 24 times
queue.add('trackPayment' , anyData , {
    repeat : {
        every : 300000,
        limit : 24,
    }
});

queue.process('trackPayment' , async (data) => {
 // this job have a limit of 24 iterations
 // would like to do some action in the iteration #24
 /*
    if (data.iteration == 24) doAction();
 */
})
queue.process("handle", function (data) {
    console.log(data.opts.repeat.count)
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM