Hi, Thank you for sharing the code and creating this great library.
I would like to know how to run code in my function 'myCustomMethod' via the Queue/Bull . Is this the right way to do it?
./models/Sport.js
export async function myCustomMethod(type, req)
{
console.log("This method should be executed via the Queue / Bull");
let computationResult = true;
return computationResult;
}
cronCustomFile.js
import { myCustomMethod } from './models/Sport.js';
cron.schedule('*/5 * * * * *', () =>
{
var battleRoyaleQueue = new Queue('battle_royale_queue');
console.log('Checking live events every 5 seconds');
battleRoyaleQueue.process(function (job, done)
{
try
{
console.log('Processing via battle_royale_queue');
myCustomMethod('live-events');
done();
}
catch (err)
{
console.log(err.message);
}
});
return true;
});
"bull": "^3.6.0"
It looks like jobs are not being added to the queue or processed.

Console

Apparently, you create the process (battleRoyaleQueue) but you never call it.
You can try a repeatable parameter:
import { myCustomMethod } from './models/Sport.js';
battleRoyaleQueue.process(function (job, done) {
try{
console.log('Processing via battle_royale_queue');
myCustomMethod('live-events');
done();
} catch (err) {
console.log(err.message);
}
});
battleRoyaleQueue.add({
repeat: {
cron: '*/5 * * * * *'
}
})
Thank you! The issue has been solved
Most helpful comment
Apparently, you create the process (battleRoyaleQueue) but you never call it.
You can try a repeatable parameter: