Complete the code to set the number of retries for a job.
class MyJob < ApplicationJob retry_on StandardError, wait: 5.seconds, attempts: [1] def perform # job code here end end
The attempts option sets how many times the job will retry on failure. Here, 5 retries are set.
Complete the code to handle a specific error type with a custom retry wait time.
class MyJob < ApplicationJob retry_on [1], wait: 10.seconds, attempts: 3 def perform # job code here end end
The job retries on Net::OpenTimeout errors with a 10-second wait between attempts.
Fix the error in the retry_on syntax to correctly retry on exceptions.
class MyJob < ApplicationJob retry_on StandardError, wait: [1], attempts: 4 def perform # job code here end end
The wait option requires a duration object like 5.seconds, not a plain number.
Fill both blanks to correctly rescue an error and retry the job with a delay.
class MyJob < ApplicationJob rescue_from [1] do |exception| retry_job wait: [2] end def perform # job code here end end
The job rescues ActiveRecord::Deadlocked errors and retries after 10 seconds.
Fill all three blanks to create a job that retries on two errors with different wait times.
class MyJob < ApplicationJob retry_on [1], wait: [2], attempts: 3 retry_on [3], wait: 20.seconds, attempts: 2 def perform # job code here end end
The job retries on StandardError with a 15-second wait and on ActiveRecord::Deadlocked with a 20-second wait.