Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
580 views
in Technique[技术] by (71.8m points)

ruby on rails - Can I redirect a failed sidekiq worker for investigation?

I am using Sidekiq with my Rails app and have about 30 workers that kick off in random orders depending on the tasks clicked on by the user in the rails app. Sometimes, a sidekiq job fails and I'll have to shut down sidekiq and investigate the error manually, which consequently interrupts all workers (initiated by that user and any other user)

I just implemented a middleware so that I can finally call a method every time a sidekiq job fails; however, now I'm wondering if there's a way that I could re-run that job in a different queue (let's say "retry_queue").

Right now, my sidekiq workers start off like this:

class TestingWorker
  include Sidekiq::Worker
  sidekiq_options queue: Rails.env.to_sym

This basically uses whatever queue the environment is running in (e.g. development or production). However, I'm not sure how to accomplish my goal given this or any other setup.

So my questions are:

  1. How can I redirect a failed sidekiq job to another queue from this middleware method that captures failed sidekiq workers?
  2. After redirecting it to another queue, how can I re-design the sidekiq job to understand this?

Ideally, if I could somehow change this:

sidekiq_options queue: Rails.env.to_sym

to something like this:

sidekiq_options queue: [something here].include? "retry_queue" ? :retry_queue : Rails.env.to_sym

Any thoughts or suggestions would be greatly appreciated.

question from:https://stackoverflow.com/questions/65846394/can-i-redirect-a-failed-sidekiq-worker-for-investigation

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Jobs that have failed all of their retries then go into the dead set and the Dead tab in the Web UI. See the Error Handling wiki page.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...