使用Delayed :: Job时使用ActiveJob设置优先级

时间:2021-04-13 01:16:55

How do you set the delayed job priority when using ActiveJob to enqueue your jobs?

在使用ActiveJob将作业排入队列时,如何设置延迟的作业优先级?

class GuestsCleanupJob < ApplicationJob
  queue_as :high_priority

  def perform(*guests)
    # Do something later
  end
end

1 个解决方案

#1


1  

It took me a while, but I found this method in the Delayed::Job documentation:

我花了一段时间,但我在Delayed :: Job文档中找到了这个方法:

Delayed::Worker.queue_attributes = {
  default:       { priority: 11 },
  high_priority: { priority: 1 },
  low_priority:  { priority: 75 }
}

I've added this to my initializers and just wanted to share if anyone else runs into this!

我已将此添加到我的初始化程序中,只是想分享是否有其他人遇到此问题!

#1


1  

It took me a while, but I found this method in the Delayed::Job documentation:

我花了一段时间,但我在Delayed :: Job文档中找到了这个方法:

Delayed::Worker.queue_attributes = {
  default:       { priority: 11 },
  high_priority: { priority: 1 },
  low_priority:  { priority: 75 }
}

I've added this to my initializers and just wanted to share if anyone else runs into this!

我已将此添加到我的初始化程序中,只是想分享是否有其他人遇到此问题!