简体   繁体   English

Bull MQ 可重复作业未触发

[英]Bull MQ repeatable job not triggering

This question is in continuation with this thread Repeatable jobs not getting triggered at given cron timing in Bull这个问题与这个线程在 Bull 的给定 cron 时间没有被触发的可重复作业继续

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.意思是在德国时区 14:07 触发作业。 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'
}

I finally figured out the solution.我终于想出了解决办法。

One thing to note is that I had not initialized a Queuescheduler instance.需要注意的一点是,我没有初始化 Queuescheduler 实例。 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.但是如果没有 Queuescheduler 实例(与队列同名),作业不会被添加到队列中。 The Queuescheduler instance acts as a book keeper. Queuescheduler 实例充当簿记员。 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.如果您不将限制设置为 1,则计划在特定时间的作业将被无限次触发。

For example: To run a job at german time 22:30 every day the configuration would look like:例如:要在德国时间每天 22:30 运行作业,配置如下所示:

    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.参考: https://docs.bullmq.io/guide/queuescheduler在上面的链接中,文档清楚地提到 queuescheduler 实例负责记录作业。

In this link - https://docs.bullmq.io/guide/jobs/repeatable , the documentation specifically warns us to ensure that we instantiate a Queuescheduler instance.在此链接 - https://docs.bullmq.io/guide/jobs/repeatable中,文档特别警告我们要确保实例化 Queuescheduler 实例。

You need to manage repeatable queues with the help of QueueSchedular.您需要在 QueueSchedular 的帮助下管理可重复的队列。 QueueSchedular takes the queue name as first parameter and connection as second. QueueSchedular 将队列名称作为第一个参数,将连接作为第二个参数。 The code will be as following:代码如下:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM