Re-Queue failed jobs with Resque
I have been working with resque for about 1-2 months now, while migrating an application from rails 2 to rails 3, I have switched from Delayed Jobs almost completely.
Sometimes, your workers / jobs fail and you need to re-queue them.
The trick is to requeue the job and remove it from the failed stats, this way, if it will fail again, the next time you re-queue the job will not be executed twice.
Here’s the code (from a rake task I have)
I have this rake running every X minutes and requeing failed tasks.
If a task keeps failing, then I can check the code in depth and check what the problem is, but sometimes it’s just failing due to HTTP error or something else not related to the code.
Hope this helps.
Drop me a line if it does or you have questions and comments.