From 5c13e8c98e6e284afa4f98e198c101dae5d78230 Mon Sep 17 00:00:00 2001 From: Gerard Cahill Date: Mon, 18 Sep 2017 10:47:48 +0100 Subject: add section to guides for discarding and retrying active jobs [ci skip] --- guides/source/active_job_basics.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'guides/source') 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`. -- cgit v1.2.3