ActiveJob 是否有具有特定优先级的队列?

Does ActiveJob have queues with specific priority?

查看下面的作业,我假设该作业在 low_priority 队列上运行。

class GuestsCleanupJob < ActiveJob::Base
  queue_as :low_priority
  #....
end

我同意这一点,但这只是队列的名称对吗?它实际上与优先级无关。例如,如果我创建了一个队列名为 :my_queue 的作业,它将被视为具有与 :low_priority 队列相同的优先级。

从文档中我无法找到任何表明我可以对排队的作业进行优先排序的信息。我知道 delayed_jobs 有这个功能,但我没在 active_job.

中找到它

优先级取决于实际的 QueueAdapter 以及此适配器的配置方式。如果您的适配器不支持优先级或未正确配置,那么 ActiveJob 也无法帮助您。

从此处了解有关适配器的更多详细信息:

http://edgeapi.rubyonrails.org/classes/ActiveJob/QueueAdapters.html

要点是:

The main point is to ensure that all Rails apps will have a job infrastructure in place. We can then have framework features and other gems build on top of that, without having to worry about API differences between various job runners such as Delayed Job and Resque. Picking your queuing backend becomes more of an operational concern, then. And you'll be able to switch between them without having to rewrite your jobs.

队列配置(包括优先级)成为适配器的责任。

作为队列配置的示例,请参阅 Sidekiq wiki:

https://github.com/mperham/sidekiq/wiki/Advanced-Options#queues