Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Catch exception but do retry with Sidekiq

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.

like image 944
Hommer Smith Avatar asked Jun 29 '15 19:06

Hommer Smith


2 Answers

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

like image 129
Mike Perham Avatar answered Sep 30 '22 05:09

Mike Perham


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.

like image 36
Collin Graves Avatar answered Sep 30 '22 05:09

Collin Graves