Module: RocketJob::Plugins::Retry
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/rocket_job/plugins/retry.rb
Overview
Automatically retry the job on failure.
The following retry algorithm is used to automatically retry a job when it fails: Failed jobs are aborted so that they cannot be restarted since a new instance has there are workers available to run. For example if workers are busy working on higher priority jobs, then the job will only run once those jobs have completed, or their priority lowered. Additionally, while the job is queued no additional instances will be enqueued, even if the next cron interval has been reached.
Note:
-
After failure the job is scheduled to run again in the future.
-
The job will not be retried if:
-
The job has expired.
-
The job fails validations.
-
The number of retry counts has been exceeded.
-
-
To see the number of times a job has failed so far:
job.failure_count
Example:
class MyJob < RocketJob::Job
include RocketJob::Plugins::Retry
# Set the default retry_count
self.max_retries = 3
def perform
puts "DONE"
end
end
# Queue the job for processing using the default cron_schedule specified above MyJob.create!
# Replace the default retry_count MyCronJob.create!(max_retries: 10)
# Disable retries for this job instance MyCronJob.create!(max_retries: 0)
Instance Method Summary collapse
-
#rocket_job_retry_on_fail? ⇒ Boolean
Returns [true|false] whether this job will be automatically retried on failure.
Instance Method Details
#rocket_job_retry_on_fail? ⇒ Boolean
Returns [true|false] whether this job will be automatically retried on failure
61 62 63 |
# File 'lib/rocket_job/plugins/retry.rb', line 61 def rocket_job_retry_on_fail? failure_count > max_retries end |