Search code examples
ruby-on-railsdelayed-jobrails-activejob

Setting priority with ActiveJob when using Delayed::Job


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

class GuestsCleanupJob < ApplicationJob
  queue_as :high_priority

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

Solution

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

    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!