method

queue_as

Importance_1
v6.1.3.1 - Show latest stable - 0 notes - Class: ClassMethods
queue_as(part_name = nil, &block) public

Specifies the name of the queue to process the job on.

class PublishToFeedJob < ActiveJob::Base
  queue_as :feeds

  def perform(post)
    post.to_feed!
  end
end

Can be given a block that will evaluate in the context of the job allowing self.arguments to be accessed so that a dynamic queue name can be applied:

class PublishToFeedJob < ApplicationJob
  queue_as do
    post = self.arguments.first

    if post.paid?
      :paid_feeds
    else
      :feeds
    end
  end

  def perform(post)
    post.to_feed!
  end
end
Show source
Register or log in to add new notes.