Reputation: 27862
I would like a Worker to be able to fetch jobs from two queues, which each queue has a diferent priority.
Right now, my worker looks like this:
class OrderWorker
include Sidekiq::Worker
sidekiq_options retry: false, queue: :orders
end
But I want to have another queue with orders that have higher priority, and make the worker consume that other queue. Is that even possible with Sidekiq? If so, at the time that you do OrderWorker.perform_async(...)
, how do you specify which queue?
Thanks!
Upvotes: 3
Views: 1849
Reputation: 17115
You can pass queue
as an option:
OrderWorker.perform_async(:queue => 'high')
OrderWorker.perform_async(:queue => 'default') # default is 'default' anyway
perform_async
and perform_in
call method push, which has a queue
argument among others.
Upvotes: 4
Reputation: 51717
To be honest I don't know if sidekiq supports this, but if it was me, I'd probably just use inheritance for this since it's just plain Ruby.
class OrderWorker
include Sidekiq::Worker
end
class HighPriorityOrderWorker < OrderWorker
sidekiq_options retry: false, queue: :high_priority_orders
end
class LowPriorityOrderWorker < OrderWorker
sidekiq_options retry: false, queue: :low_priority_orders
end
Upvotes: 0