【问题标题】:Rails5, how to retry perform an ActiveJob a specific number of times (max attempts)Rails5,如何重试执行 ActiveJob 特定次数(最大尝试次数)
【发布时间】:2017-09-22 06:34:57
【问题描述】:

现在我的后台进程使用 DelayedJobs 运行,我看到 DelayedJob 上的 max_attempts 功能非常方便,我如何在 ActiveJob 中复制它?

这取决于队列系统吗? ActiveJob 对此有什么抽象配置吗?

【问题讨论】:

    标签: ruby-on-rails-5 delayed-job rails-activejob


    【解决方案1】:

    gem ActiveJob::Retry 成功了:

    class MyJob < ActiveJob::Base
      include ActiveJob::Retry.new(
        :strategy => :variable,
        :delays => [10.seconds, 1.minute, 10.minutes, 15.minutes]
      )
    end
    

    【讨论】:

      猜你喜欢
      • 2013-05-30
      • 2016-01-13
      • 2012-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-06
      相关资源
      最近更新 更多