[Backgroundrb-devel] Exception Handling
adam at thewilliams.ws
Tue Jun 23 20:10:48 EDT 2009
I ended up creating a 'RobustWorker', which all our workers subclass.
Then the methods use notify_on_failure :tries => 5 do work; end
That method runs the block in a begin rescue, up to five times,
sending me an email if it is never successful. Of course, any db work
should be done in a transaction.
On Jun 23, 2009, at 6:27 AM, Tobias Overkamp <tov-backgroundrb at overkamp.org
> Hi folks!
> I'm still starting with BackgroundRB and I wonder if it is possible
> to to put some kind of exception handling (begin/rescue etc.) around
> each method in my worker.
> In the example below I want to make sure that the whole method could
> be processed correctly before I commit the data in the database.
> Of course I don't want to write the begin-rescue idiom in every
> method (DRY). Is there some kind of hook/callback that I'm missing?
> class TransferWorker < BackgrounDRb::MetaWorker
> set_worker_name :transfer_worker
> def request_transfer_from_registry
> ActiveRecord::Base.transaction do
> transfer = Order::OrderTransfer.new(:xml => args[:xml])
> rescue Exception => e
> #notify whomever...
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
More information about the Backgroundrb-devel