提交 3d7d1e21 编写于 作者: R Ryuta Kamizono 提交者: GitHub

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]
......@@ -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`.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册