Reputation:
I have a Sidekiq job which can fail. The job contains a few operations making requests to REST API. In case of failure Sidekiq will repeat the job and it's by default. However, I don't want it to repeat the job from the beginning, it should repeat from that operation which has caused the failure and up to the point when the last operation has been successful. How can I do that?
Upvotes: 0
Views: 52
Reputation: 121000
Out of the box this is obviously impossible. Sidekiq does not parse your code and he knows barely nothing about where the error occurred. One should break the job into chain of small jobs, one running other.
class Job1
def perform
...
Job2.perform_async
end
end
...
That way as, say, Job3 failed, it will be rescheduled and everything will behave exactly as you want.
Upvotes: 2