I crawl leads
from other sites and activate them at mine. With Sidekiq
I run a HealthCheckerWorker
every hour to deactivate the lead on my site unless it's still up and running on the other site.
Sometimes the HealthCheckerWorker
throws an error, iE: bad URI
etc... My dilemma here is that if the job fails 10 times, now in the Dead Job Queue, the lead
is still considered active although it may be long gone on the other site.
I thought the solution would be to add a sidekiq_retries_exhausted
block like so:
sidekiq_retries_exhausted do |lead_id|
Lead.find(lead_id).deactivate
end
But as defined in the docs:
The hook receives the queued message as an argument. This hook is called right before Sidekiq moves the job to the DJQ.
So it only gets the message
as an argument. How can I deactivate the lead after the retries are exhausted?
The message is the entire job, including the arguments. Just pull out the arguments.
sidekiq_retries_exhausted do |msg|
lead_id = msg['args'].first
Lead.find(lead_id).deactivate
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With