I'm using bull to run cron jobs with nodejs. This is my file, when debugging I only see first test job running every 2 minutes, but I dont see the other one. So here in my case I'm always getting test1 printed and never goes to the other job.
Can Anyone help please? thanks
const Queue = require('bull');
const queue = new Queue('test', 'redis://127.0.0.1:6379');
const transactionCron = async () => {
const jobs = await queue.addBulk(['test',
{
action: 'test1',
}, { repeat: { cron: "*/2 * * * *" } },
{
action: 'test2',
}, { repeat: { cron: "* * * * *" } },
]);
// console.log(queue, ' queue');
};
queue.process(async(job, done) => {
console.log("transaction queue processing job");
console.log(job.data.action);
try {
switch (job.data.action) {
case 'test1':
console.log((job.data.action) , "data");
break;
case 'test2':
console.log(job.data.action, "data");
break;
default:
logger.warn("Unknown job action", job);
break;
}
done();
} catch (error) {
done(error);
}
});