collectiveidea / delayed_job

Database based asynchronous priority queue system -- Extracted from Shopify
http://groups.google.com/group/delayed_job
MIT License
4.82k stars 956 forks source link

Pool workers and default queue #828

Closed x3mka closed 2 months ago

x3mka commented 9 years ago

Is it possible to run X workers for the default queue and Y workers for a named queue?

script/delayed_job --pool=default:X --pool=named:Y start doesn't pick jobs from default queue (I think it expects queue name be explicitly set to 'default')

script/delayed_job --pool=named:Y --pool=*:X start runs X+Y workers for 'named' queue.

alkuzad commented 9 years ago

We have found similar problem, the solution is pretty simple. Write plugin that calls

lifecycle.before(:enqueue) do |job|
  next if job.queue
  job.queue = 'global'
end

and

lifecycle.before(:execute) do |worker|
  next if worker.queues != []
  worker.queues = ['global']
end

and add it to config/initializers with Delayed::Worker.plugins << Delayed::Plugins::StrictGlobalQueue::Plugin

Yegorov commented 5 years ago

Since 3.0.4 version (commit) of DJ you can specify a default queue name. For example:

# config/initializers/delayed_job_config.rb
Delayed::Worker.default_queue_name = 'default'
albus522 commented 2 months ago

Closing stale