0

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();
 */
})
  • You might need to set something up by hand to get this functionality. Have you tried adding a counter that is incremented within the trackPayment process function? Something like instantiating `let trackPaymentIteration = 0` outside the function and incrementing within the process function upon execution (`++trackPaymentIteration`). – GenericUser Jan 01 '22 at 03:18
  • Surely this won't work in my case, I may have bunch of jobs with different ids, each job track a certain payment transaction, so a single variable won't handle this – Ahmed Mohsen Jan 04 '22 at 21:12

1 Answers1

0
queue.process("handle", function (data) {
    console.log(data.opts.repeat.count)
});
  • Your answer could be improved by adding more information on what the code does and how it helps the OP. – Tyler2P Mar 20 '22 at 17:27