Sidekiq list all jobs [queued + running]

怎甘沉沦 提交于 2019-12-04 02:32:21

if you want to list all currently running jobs from console, try this

workers = Sidekiq::Workers.new
workers.each do |_process_id, _thread_id, work|
  p work
end

a work is a hash.

to list all queue data.

queue = Sidekiq::Queue.all
queue.each do |job|
  p job.klass, job.args, job.jid
end

for a specific queue change this to Sidekiq::Queue.new('queue_name')

similarly you can get all scheduled jobs using Sidekiq::ScheduledSet.new

Assuming you passed the Hash as the argument to Sidekiq when you enqueued.

args = {
  "student_id": 1,
  "student_name": "Michael Moore"
    }

YourWorker.perform_in(1.second,args)

Then anywhere from your application, you could retrieve it as following

      ss = Sidekiq::ScheduledSet.new
      student_id_list = ss.map{|job| job['args'].first["student_id"]}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!