Disable automatic retry with ActiveJob, used with Sidekiq

后端 未结 6 1016
名媛妹妹
名媛妹妹 2021-02-03 23:58

Is there a way to disable automatic retry with ActiveJob and Sidekiq ?

I know that with Sidekiq only, we just have to put

sidekiq_options :retry => f         


        
6条回答
  •  逝去的感伤
    2021-02-04 00:40

    You can catch up the exception and to do nothing instead retry or to configure retry:

      class ExampleJob < ActiveJob::Base
        rescue_from(StandardError) do |exception|
          Rails.logger.error "[#{self.class.name}] Hey, something was wrong with you job #{exception.to_s}"       
        end
    
        def perform
          raise StandardError, "error_message"
        end
      end
    
      class ExampleJob < ActiveJob::Base
        rescue_from(StandardError) do |exception|
          retry_job wait: 5.minutes, queue: :low_priority     
        end
    
        def perform
          raise StandardError, "error_message"
        end
      end
    

    For running retrying you can use retry_on method retry_on method doc

    Sidekiq wiki for retries with Active Job integration

提交回复
热议问题