Bull queue nestjs not processing the job at correct time

2.8k views Asked by At

I am trying to create a time in milliseconds to pass it to delay using bull queue. I can correctly get time for the processing of the job, but somehow the job is not being called at a specific time. Some time it take more than 30 or 45 seconds to process the job from it's actual start of time.

for example if delay time is for 2 minutes. it execute in 2 minutes and 45 seconds. I am unable to find the reason. I want it to run only at 2 minutes. Below is my code

const startTime = moment().tz(timeZone).set('second', 0).valueOf();
const endTime = moment(time)
      .subtract(timeToSubtract, 'minutes')
      .tz(timeZone)
      .set('second', 0)
      .valueOf();
const scheduleTime = endTime - startTime

this.queue.add(
     'test-queue',
      {
        mesage,
      },
      {
        delay: scheduleTime,
        removeOnComplete: true,
      }
    );
0

There are 0 answers