Sidekiq middleware that allows capturing exceptions and throwing only after last retry, useful for integrations with sentry, airbrake, rollbar, honeybadger etc, when you don't want to raise exceptions on each retry.
$ gem install sidekiq-seize
class MyWorker
include Sidekiq::Worker
sidekiq_options seize: true
def perform(params)
...
end
end
Seize only when certain types of exceptions occur
class MyWorker
include Sidekiq::Worker
sidekiq_options seize: true, seize_exceptions_classes: [ActiveRecord::Deadlocked]
def perform(params)
...
end
end
This middleware inherits from sidekiq JobRetry
middleware, all exceptions in each retry until the final retry are captured and job is manually put into retry. For the last retry exception is raised naturally.
It will result in trigger of on_success callback even when job went into retry.