From 8457e5eb1dfad9a41ac44547ae4d96f3475570dc Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 29 Jul 2016 14:23:39 -0700 Subject: Allow retries to happen with different priority and queue --- activejob/lib/active_job/exceptions.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'activejob/lib/active_job/exceptions.rb') diff --git a/activejob/lib/active_job/exceptions.rb b/activejob/lib/active_job/exceptions.rb index 7d8bca4561..006b067bcf 100644 --- a/activejob/lib/active_job/exceptions.rb +++ b/activejob/lib/active_job/exceptions.rb @@ -14,6 +14,8 @@ module ActiveJob # ==== Options # * :wait - Re-enqueues the job with the specified delay in seconds (default: 3 seconds) # * :attempts - Re-enqueues the job the specified number of times (default: 5 attempts) + # * :queue - Re-enqueues the job on a different queue + # * :priority - Re-enqueues the job with a different priority # # ==== Examples # @@ -24,10 +26,10 @@ module ActiveJob # # Might raise Net::OpenTimeout when the remote service is down # end # end - def retry_on(exception, wait: 3.seconds, attempts: 5) + def retry_on(exception, wait: 3.seconds, attempts: 5, queue: nil, priority: nil) rescue_from exception do |error| logger.error "Retrying #{self.class} in #{wait} seconds, due to a #{exception}. The original exception was #{error.cause.inspect}." - retry_job wait: wait if executions < attempts + retry_job wait: wait, queue: queue, priority: priority if executions < attempts end end -- cgit v1.2.3