Reputation: 8631
I have a worker like so:
class MassDispatchServiceWorker
include Sidekiq::Worker
sidekiq_options queue: :bulk
def perform(message_params)
DispatchService.new(message_params).dispatch!
end
end
However I have a need for the same exact method but to pass in a queue as a variable. Sometimes I want the queue to be bulk, other times I'll need something else. Is that possible with sidekiq?
Upvotes: 5
Views: 5803
Reputation: 330
There is another way:
MyWorker.set(queue: 'foo').perform_async(1)
From https://github.com/mperham/sidekiq/issues/2152#issuecomment-290376790
Upvotes: 12
Reputation: 22228
Use the Sidekiq::Client
API.
Sidekiq::Client.push('class' => MassDispatchServiceWorker, 'args' => [], 'queue' => whatever)
Upvotes: 0