diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-09-18 22:08:17 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-18 22:08:17 +0900 |
commit | 3d7d1e2165c9aa6c304e063d27437df0f234b3ef (patch) | |
tree | 822d629b29011f503cedacd0508a28ba6754ecca | |
parent | 00cc168f75ebd64e7ecf3c2d12a597fb167747d8 (diff) | |
parent | 5c13e8c98e6e284afa4f98e198c101dae5d78230 (diff) | |
download | rails-3d7d1e2165c9aa6c304e063d27437df0f234b3ef.tar.gz rails-3d7d1e2165c9aa6c304e063d27437df0f234b3ef.tar.bz2 rails-3d7d1e2165c9aa6c304e063d27437df0f234b3ef.zip |
Merge pull request #30643 from gerardc/gerardc/guides-add-active-job-retrying-discarding-section
Add section to guides for discarding and retrying active jobs [ci skip]
-rw-r--r-- | guides/source/active_job_basics.md | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/guides/source/active_job_basics.md b/guides/source/active_job_basics.md index 7a3ff12b63..f94e9fe197 100644 --- a/guides/source/active_job_basics.md +++ b/guides/source/active_job_basics.md @@ -389,6 +389,25 @@ class GuestsCleanupJob < ApplicationJob end ``` +### Retrying or Discarding failed jobs + +It's also possible to retry or discard a job if an exception is raised during execution. +For example: + +```ruby +class RemoteServiceJob < ActiveJob::Base + retry_on CustomAppException # defaults to 3s wait, 5 attempts + + discard_on ActiveJob::DeserializationError + + def perform(*args) + # Might raise CustomAppException or ActiveJob::DeserializationError + end +end +``` + +To get more details see the API Documentation for [ActiveJob::Exceptions](http://api.rubyonrails.org/classes/ActiveJob/Exceptions/ClassMethods.html). + ### Deserialization GlobalID allows serializing full Active Record objects passed to `#perform`. |