Search code examples
ruby-on-railssidekiqrails-activejob

Rails 5 + ActiveJob + Sidekiq: Stop and log error after 10 retries


Trying to program a job that after 10 retries (from all exception types) will report a failure and die. Can't get it to work. Tried this answer and this one too. Neither worked. The best solution would be to access retry_count from within the perform method.


Solution

  • I think what you're asking for is the sidekiq_retries_exhausted hook. It will be called once your retries are up and job will move to dead queue. Just set retries to 10 and implement that hook.

    config.death_handlers might also be interesting.

    See docs here: https://github.com/mperham/sidekiq/wiki/Error-Handling#configuration