Sidekiq - Reschedule failed job

帅比萌擦擦* 提交于 2019-12-11 10:14:14

问题


I have a background job using Sidekiq connecting to another service of mine like this:

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

Sometimes this ABCClient is down and I would like to reschedule the "perform" job in this case. Like this:

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

回答1:


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

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



来源:https://stackoverflow.com/questions/25937654/sidekiq-reschedule-failed-job

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!