aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib/active_job/exceptions.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2016-07-29 14:23:39 -0700
committerDavid Heinemeier Hansson <david@loudthinking.com>2016-07-29 14:23:39 -0700
commit8457e5eb1dfad9a41ac44547ae4d96f3475570dc (patch)
tree4203aec26b1d33986a7ca94867c61b4656fc6d95 /activejob/lib/active_job/exceptions.rb
parentb00214d214c6b0a2208d5861de1a7b158accddf0 (diff)
downloadrails-8457e5eb1dfad9a41ac44547ae4d96f3475570dc.tar.gz
rails-8457e5eb1dfad9a41ac44547ae4d96f3475570dc.tar.bz2
rails-8457e5eb1dfad9a41ac44547ae4d96f3475570dc.zip
Allow retries to happen with different priority and queue
Diffstat (limited to 'activejob/lib/active_job/exceptions.rb')
-rw-r--r--activejob/lib/active_job/exceptions.rb6
1 files changed, 4 insertions, 2 deletions
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
# * <tt>:wait</tt> - Re-enqueues the job with the specified delay in seconds (default: 3 seconds)
# * <tt>:attempts</tt> - Re-enqueues the job the specified number of times (default: 5 attempts)
+ # * <tt>:queue</tt> - Re-enqueues the job on a different queue
+ # * <tt>:priority</tt> - 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