【问题标题】:Does resque automatically retries failed jobs?resque 会自动重试失败的作业吗?
【发布时间】:2016-11-04 07:16:20
【问题描述】:

或者是否有一个可以接受重试次数的配置。任何输入将不胜感激。我看到了这个链接Restart failed jobs of a specific worker in resque,并且知道如何手动重试作业。我正在寻找使这一步自动化。

【问题讨论】:

    标签: resque resque-scheduler


    【解决方案1】:

    您可以使用当作业失败时调用的 resque 失败钩子。

    您可以覆盖此方法或使用某些插件来执行此操作。 一旦作业失败记录并仅从此处重试。

    来自 resque 代码库的代码,文件:resque-1.27.1/lib/resque/job.rb

     # Given an exception object, hands off the needed parameters to
    # the Failure module.
    def fail(exception)
      begin
        run_failure_hooks(exception)
      rescue Exception => e
        raise e
      ensure
        Failure.create \
          :payload   => payload,
          :exception => exception,
          :worker    => worker,
          :queue     => queue
      end
    end
    

    【讨论】:

      【解决方案2】:

      不,Resque 没有内置的重试功能。

      您可以使用插件resque-retry,或者如果您已经在使用ActiveJob with Resque,您可以使用本机retry_on 功能。

      请注意,resque-retry 似乎不适用于 ActiveJob,所以它是非此即彼的。

      【讨论】:

        猜你喜欢
        • 2015-03-24
        • 2020-04-19
        • 2012-12-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-11-11
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多