Catch exception but do retry with Sidekiq

空扰寡人 提交于 2020-05-29 04:17:05

问题


By default sidekiq will retry any jobs that throw an exception. That is fine. However, I want to be able to catch that exception so that my exception handler doesn't get notified, and then retry the job. How do I accomplish this in react?

So my code looks like this:

def perform
  ...
rescue ExcClass => ex
  # log
end

But I want to actually retry that job.


回答1:


Configure your error service client to ignore ExcClass. Sidekiq will retry, you don't get error reports.




回答2:


If I'm following your question correctly, it sounds like you may want a custom error handler to do what you want:

Sidekiq.configure_server do |config|
  config.error_handlers << Proc.new {|exception,context_hash| MyErrorService.notify(exception,context_hash) }
end

By default, Sidekiq will continue to retry your jobs automatically.

Does this answer your question? It's slightly confusing. Here are the docs from which I pulled the above information.



来源:https://stackoverflow.com/questions/31123960/catch-exception-but-do-retry-with-sidekiq

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