rescue Resque
Chiel Wester wo 14 jul 10
A couple of months ago, i posted an article on this blog about implementing resque for performing background jobs.
There have been several updates to the resque core since then, one of them is the possibility to write plugins for resque without having to change the main functionality of resque.
One of these plugins that was created is resque-retry. When you include this plugin in your Job class, any failed job will be retried several times when it raises an error. This becomes very useful when your job uses some external service that can give the pain of timeouts.
The plugin also has the possibility to only retry on specific exceptions (e.g. Timeout, NetworkError). At the moment the job is simply deleted when the retry limit is exceeded. Of course you could overwrite this functionality to notify you in some way that a job failed too many times:
def on_failure_retry(exception, *args)
if retry_criteria_valid?(exception, *args)
try_again(*args)
else
# Notify me about this error!
Resque.redis.del(redis_retry_key(*args))
end
end
Check for examples and documentation the github project page
This plugin depends on the resque-scheduler plugin that gives you the possibility to schedule jobs in a cron-like way or to schedule a job at some time in the future.
Gepost in hor | 0 reacties
Welcome to Holland On Rails
This weblog is the official Ruby techblog from the guys at Holder, a Ruby development company. Holder is also the company behind the RubyAndRails Europe Conference in Amsterdam.Recente Jobs
Bekijk alle jobs »»
Gereedschapskist
Onmisbare tools vooriedere developer!
- Ruby On Rails
Framework voor de web 2.0 developer. Eindelijk vooruitgang! - TextMate
Editor for true pro's
Typ, tab, top :-)
Nee, niet voor Win. - Made On A Mac
En nou is het over met die saaie grijze Windows bak van je!
Auteurs op deze site
Chris Obdam
'Less is more' evangelist, past dit ook dagelijks toe op zijn tandenborstel.Chiel Wester
Snelheidswonder op Ruby wielen. Leuk om mee te pair-programmen ;-)
Plaats je reactie