README.md in resque_mailer-2.2.5 vs README.md in resque_mailer-2.2.6

- old
+ new

@@ -1,11 +1,11 @@ # ResqueMailer [![Gem Version](https://badge.fury.io/rb/resque_mailer.png)](http://badge.fury.io/rb/resque_mailer) [![Build Status](https://secure.travis-ci.org/zapnap/resque_mailer.png)](http://travis-ci.org/zapnap/resque_mailer) A gem plugin which allows messages prepared by ActionMailer to be delivered -asynchronously. Assumes you're using Resque (http://github.com/defunkt/resque) +asynchronously. Assumes you're using [Resque](https://github.com/resque/resque) for your background jobs. Note that recent (2.0+) versions of Resque::Mailer only work with Rails 3.x or 4.x. For a version compatible with Rails 2, specify v1.x in your Gemfile. @@ -56,15 +56,33 @@ resque_mailer in a shared environment. You will need to use the new queue name when starting your workers. QUEUE=application_specific_mailer rake environment resque:work -Custom handling of errors that arise when sending a message is possible by +Custom handling of errors that arise when sending a message is possible by assigning a lambda to the `error_hander` attribute. +There are two supported lambdas for backwards compatiability: + +The first lamba will be deprecated in a future release: + ```ruby Resque::Mailer.error_handler = lambda { |mailer, message, error| # some custom error handling code here in which you optionally re-raise the error +} +``` + +The new lamba contains two other arguments, action and args, which allows +mailers to be requeued on failure: + +```ruby +Resque::Mailer.error_handler = lambda { |mailer, message, error, action, args| + # Necessary to re-enqueue jobs that receieve the SIGTERM signal + if exception.is_a?(Resque::TermException) + Resque.enqueue(mailer, action, *args) + else + raise exception + end } ``` ### Resque::Mailer as a Project Default