7

I know we can do:

sidekiq_options queue: "Foo"

But in this case it's the Worker which is assigned to only one queue: "Foo".

I need to assign a Job (and not a Worker) in specific queue. With Resque it's easy:

Resque.enqueue_to(queue_name, my_job)

Further, for concurrency problem, i need to limit the number of Worker on each queue at 1.

How can I do this?

rudolph9
  • 8,021
  • 9
  • 50
  • 80
Matrix
  • 3,458
  • 6
  • 40
  • 76

2 Answers2

6

You might use https://github.com/brainopia/sidekiq-limit_fetch

and then:

Sidekiq::Client.push({
    'class' => GuidePdfWorker,
    'queue' => queue_name,
    'args'  => [my_job]
})
Sidekiq::Queue[queue_name].limit = 1

But you have to declare your queue_name in the config/sidekiq.yml

Maxime
  • 118
  • 1
  • 5
  • yes, it's a good thing, but i need to dynamic queue name, so if i have to define them in a file, it's not good solution. Exemple: if i have games, jobs belongs to a game. I want create dynamic queue name like "game_" + game_id and push the jobs in a good queue. You undestand? How can i do that? – Matrix Nov 22 '13 at 15:16
  • I asked the same thing :) http://stackoverflow.com/questions/20133346/how-can-i-create-sidekiq-queues-with-variable-names-at-runtime – Maxime Dec 03 '13 at 18:22
  • yes, i know that, but sidekiq-limit-fetch and sidekiq-dynamic-queues are incompatibles plug-in ! I need the both but i can't :'( any idea? – Matrix Dec 03 '13 at 19:05
1

I have achieved the above said functionality using the sidekiq limit fetch. You can set dynamic queue mode to true and specify the queues in the Sidekiq::Client.push

And set the process limit to the specific queue. We can either set the process limit or we can ignore and simply it process as per the sidekiq default limit

logesh
  • 2,572
  • 4
  • 33
  • 60