2014-09-19 86 views
0

我有使用Sidekiq后台作业连接到像这样我的另一个服务:Sidekiq - 重新安排失败的作业

def perform(id) 
     user = ABCClient.instance.user(id) 
     ... 
    end 

有时这ABCClient已关闭,我想重新安排“执行”工作在这种情况下, 。 像这样:

def perform(id) 
     begin 
      user = ABCClient.instance.user(id) 
     rescue => e 
      # Reschedule job 
     end 
     ... 
    end 

回答

4

https://github.com/mperham/sidekiq/wiki/Scheduled-Jobs

rescue => e self.class.perform_in(5.minutes, id) end

+0

我有以下错误 “5未定义的方法'分钟:Fixnum对象” - 你确定这是可以做到这样? – titibouboul 2014-09-23 15:12:29

+1

这是一个轨道主义。需要有效的支持。 – 2014-09-23 22:47:06