3

This question is in continuation with this thread Repeatable jobs not getting triggered at given cron timing in Bull

I am also facing the same problem. How should I specify the timezone? I tried to specify as

repeat: { cron: '* 7 14 * * *', tz: 'Europe/Berlin'}

Meaning trigger the job at 14:07 German time zone. Though the job is listed in the queue, but the job is not triggered.

I also tried repeat:

{
   cron: '* 50 15 * * *', 
   offset: datetime.getTimezoneOffset(), 
   tz: 'Europe/Berlin'
}

2 Answers2

3

I finally figured out the solution.

One thing to note is that I had not initialized a Queuescheduler instance. Ofcourse timezone also plays a crucial role. But without a Queuescheduler instance (which has the same name as the Queue), the jobs doesnt get added into the queue. The Queuescheduler instance acts as a book keeper. Also take care about one more important parameter "limit". If you dont set the limit to 1, then the job which is scheduled at a particular time will get triggered unlimited number of times.

For example: To run a job at german time 22:30 every day the configuration would look like:

    repeat: { 
        cron: '* 30 22 * * *',
        offset: datetime.getTimezoneOffset(),
        tz: 'Europe/Berlin',
        limit: 1
    }

Reference: https://docs.bullmq.io/guide/queuescheduler In this above link, the documentation clearly mentions that the queuescheduler instance does the book keeping of the jobs.

In this link - https://docs.bullmq.io/guide/jobs/repeatable, the documentation specifically warns us to ensure that we instantiate a Queuescheduler instance.

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • "From BullMQ 2.0 and onwards, the QueueScheduler is not needed anymore, so the information below is only valid for older versions." (source: https://docs.bullmq.io/guide/queuescheduler) – RushPL Dec 14 '22 at 20:22
0

You need to manage repeatable queues with the help of QueueSchedular. QueueSchedular takes the queue name as first parameter and connection as second. The code will be as following:

const queueSchedular = new QueueSchedular(yourQueue.name, { connection });