resque会自动重试失败的作业吗?

时间:2016-07-01 19:34:13

标签: resque resque-scheduler

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

2 个答案:

答案 0 :(得分:0)

您可以使用resque failure hooks,只要作业失败就会调用它。

您可以覆盖此方法或使用某些插件执行此操作。 一旦作业失败,只能从此处重试。

来自resque code base的代码,文件: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

答案 1 :(得分:0)

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

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

请注意,resque-retry似乎不适用于ActiveJob,因此它要么是要么是或。