Hi,
I would like to get notifications (slack, mail, sentry or anything) when a job enters the dead queue.
An on_dead callback would do the job.
I could poll and check if there is dead jobs every x minutes but It's not ideal imo.
Do we have that? What would be the best way to achieve that?
Thanks!
Best approach would be to implement this:
Sidekiq.configure_server do |config|
config.on(:dead) do |job_hash|
# do something, e.g.
# SlackNotifier.dead_job(job)
end
end
That's what I'm looking for :)
Thank you!
Is this mentioned somewhere on the Wiki? Can't find it.
It's not implemented but would take about 10 lines of code. I look forward to your PR! :-)
Reading the code I found a similar feature available since 4.1.1 :
Sidekiq.configure_server do |config|
config.default_retries_exhausted = -> (job, ex) do
Sidekiq.logger.info "#{job['class']} job is now dead"
end
end
If anyone got here late and nothing works, here is the right approach:
Sidekiq.configure_server do |config|
config.death_handlers << ->(job, ex) do
# do stuff
# job keys: ["class", "args", "retry", "queue", "backtrace", "jid", "created_at", "enqueued_at", "error_message", "error_class", "failed_at", "retry_count", "error_backtrace"]
end
end