Help us understand the problem. What is going on with this article?

#Rails + shoryuken gem + #AWS SQS でリトライ処理の動作確認をする

ランダムに失敗するジョブを作っておく

class ShoryukenRandomFailureJob < ApplicationJob
  queue_as :example1
  queue_as :example2

  def perform(message)
    if rand(1..3) <= 1
      puts '-' * 100
      puts 'JOB WOKED'
      puts '-' * 100
      puts "message: #{message}"
      puts '-' * 100
    else
      raise 'Job Failed'
    end
  end
end

ジョブを実行する

bundle exec rails runner 'ShoryukenRandomFailureJob.perform_later("ABC")'

Workerで例外が確認できる

image

AWS SQS のコンソールで処理中のメッセージが増える

image

いずれジョブが成功する

image

Workerがメッセージ = ジョブを自動削除して、処理中のメッセージ数が0になる

image

ただし shoryuken worker の設定で自動削除を有効化している場合に限る

class ShoryukenWorker
  include Shoryuken::Worker

  shoryuken_options queue: 'example1', auto_delete: true
  shoryuken_options queue: 'example2', auto_delete: true
  shoryuken_options queue: 'example3', auto_delete: true
end

NOTE

  • shoryuken的にリトライをしているか、SQS的にリトライをしているかはまだ不明

Original by Github issue

https://github.com/YumaInaura/YumaInaura/issues/2464

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away