简体   繁体   English

公牛队列包配置混乱

[英]Bull queue package configuration confusion

I am using bull package from npm to manage a queue "npm i bull". 我使用来自npm的bull包来管理队列“npm i bull”。 I got it mostly figured out and working but there seems to be something that I dont understand in the configuration. 我得到它主要是想通了并且工作但是在配置中似乎有一些我不理解的东西。

In the configuration for a new queue theres this one: 在新队列的配置中,这个是:

 maxStalledCount: number = 1; // Max amount of times a stalled job will be re-processed.

this is from the reference page of their github and then theres another configuration that you can define: 这是来自他们的github的参考页面,然后是你可以定义的另一个配置:

attempts: number; // The total number of attempts to try the job until it completes.

I should mention that this is relevant for failing jobs 我应该提一下,这与失败的工作有关

firstly, it seems that only attempts actually determines anything, regardless of what is in maxStalledCount, the script will only follow the amount of attempts set. 首先,似乎只有尝试实际上确定了任何内容,无论maxStalledCount中是什么,脚本都只会遵循设置的尝试次数。 for example: if i set attempts to 3 and maxStalledCount to 1, it will STILL do 3 attempts and then move it to the failed when it "ran out of attempts" different example: if i set attempts to 1 and maxStalledCount to 3 it will only do 1 attempt before throwing it into failed. 例如:如果我将尝试设置为3并将maxStalledCount设置为1,则它仍然会进行3次尝试,然后在“尝试用尽”时将其移至失败的示例:如果我将尝试设置为1并将maxStalledCount设置为3则将在将其投入失败之前只做1次尝试。

Can someone explain the difference? 有人可以解释这个区别吗? I could not find anything online. 我在网上找不到任何东西。

Ultimately what I want my queue to do is attempt something up to 5 times, then move it to failed, and to be able to get all the failed jobs at a later time to retry them, how would i configure that? 最终我希望我的队列做的是尝试最多5次,然后将其移动到失败,并且能够在稍后的时间获得所有失败的作业以重试它们,我将如何配置?

added link to the reference page: https://github.com/OptimalBits/bull/blob/develop/REFERENCE.md 添加了参考页面的链接: https//github.com/OptimalBits/bull/blob/develop/REFERENCE.md

Thanks. 谢谢。

There is a difference between a 'stalled' job and a 'failed' job. “停滞”工作和“失败”工作之间存在差异。 According to this note in the bull docs , a job is considered stalled when: 根据牛市文件中的这一说明,在下列情况下 ,工作被视为停滞:

  1. The Node process running your job processor unexpectedly terminates. 运行您的作业处理器的节点进程意外终止。
  2. Your job processor was too CPU-intensive and stalled the Node event loop, and as a result, Bull couldn't renew the job lock. 您的作业处理器太耗费CPU并且停止了Node事件循环,因此Bull无法续订作业锁定。

maxStalledCount is a safeguard so problematic jobs won't get restarted indefinitely. maxStalledCount是一种安全措施,因此有问题的作业无法无限期地重新启动。

If you are dealing with failed jobs, the attempts option dictates the number of attempts. 如果您正在处理失败的作业,则尝试选项会指示尝试次数。

As for your desired behavior: 至于你想要的行为:

  • set your attempts option to 5 将您的尝试选项设置为5
  • at some later time, gather an array of failed jobs with: 稍后,收集一系列失败的工作:

    const failedJobs = cacheQueue.getFailed();

  • Retry the failed jobs with: 使用以下命令重试失败的作业:

    failedJobs.forEach(job => job.retry());

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

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