blob: 12f9e1cc17d42517e44ce187e6f9919bd3263560 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
## Rails 5.1.0.alpha ##
* Added declarative exception handling via `ActiveJob::Base.retry_on` and `ActiveJob::Base.discard_on`.
Examples:
class RemoteServiceJob < ActiveJob::Base
retry_on CustomAppException # defaults to 3s wait, 5 attempts
retry_on AnotherCustomAppException, wait: ->(executions) { executions * 2 }
retry_on ActiveRecord::StatementInvalid, wait: 5.seconds, attempts: 3
retry_on Net::OpenTimeout, wait: :exponentially_longer, attempts: 10
discard_on ActiveJob::DeserializationError
def perform(*args)
# Might raise CustomAppException or AnotherCustomAppException for something domain specific
# Might raise ActiveRecord::StatementInvalid when a local db deadlock is detected
# Might raise Net::OpenTimeout when the remote service is down
end
end
*DHH*
Please check [5-0-stable](https://github.com/rails/rails/blob/5-0-stable/activejob/CHANGELOG.md) for previous changes.
|