Resque重试重试没有延迟

时间:2012-09-25 23:41:42

标签: ruby-on-rails resque resque-retry

这是我的代码

class ExampleTask
    extend Resque::Plugins::ExponentialBackoff
    @backoff_strategy = [0, 20, 3600]
    @queue = :example_tasks
    def self.perform
      raise
    end
  end

我遇到了一个问题,每当我在本地将此任务排入队列时,Resque似乎会在不遵守退避策略的情况下立即重试任务。有没有人曾经遇到过这个问题?

2 个答案:

答案 0 :(得分:0)

升级到1.0.0实际上解决了这个问题。

答案 1 :(得分:0)

对于任何未来的读者,数组@backoff_strategy中的第一个整数是Resque-Retry在第一次重试之前等待的时间。来自github readme

key: m = minutes, h = hours

              no delay, 1m, 10m,   1h,    3h,    6h
@backoff_strategy = [0, 60, 600, 3600, 10800, 21600]
@retry_delay_multiplicand_min = 1.0
@retry_delay_multiplicand_max = 1.0

The first delay will be 0 seconds, the 2nd will be 60 seconds, etc... Again, tweak to your own needs.
相关问题