Delay isn't honored when using multiple workers
Created by: claudiopetrini
Hello,
I'm using bull for waiting a specific amount of time with the delay
option.
Everything works fine until there's only one worker that's processing the queue, as soon as there are multiple workers delay seems not to be honored.
Here a snippet of code of the producer:
const Queue = require('bull');
const redisConfig = {
host: 'localhost',
port: '6379',
db: 2,
};
const queue = new Queue('steps', {
redis: redisConfig,
prefix: 'wait',
});
for (let i = 1; i <= 5; i++) {
const wait = i * 3000;
const options = {
delay: wait,
removeOnComplete: true,
removeOnFail: true,
};
const data = {
waited: wait,
};
queue.add(data, options)
.then(() => {
console.log(`ADDED ${i}`);
})
.catch((err) => {
console.log(err);
});
}
And here's a snippet of code of the workers :
const Queue = require('bull');
const redisConfig = {
host: 'localhost',
port: '6379',
db: 2,
};
const queue = new Queue('steps', {
redis: redisConfig,
prefix: 'wait',
});
queue.process((job, done) => {
console.log('PROCESSING', job.data);
done();
});
When multiple workers are up jobs are received without honoring wait time, am I missing something? Thank you.