In README for Delayed Job 3:
DJ 3 introduces Resque-style name queues while maintaining DJ style priority. The goal is to provide a system for grouping tasks that will be handled by separate pools of workers that can be scaled and controlled individually.
Jobs can be assigned to a queue by setting the queue option:
object.delay(:queue => 'tracking').method
Delayed::Job.enqueue job, :queue => 'tracking'
handle_asynchronously :tweet_later, :queue => 'tweets'
script / delayed_job can be used to control the background process, which will begin to perform tasks.
, gem "" Gemfile , rails generate delayed_job.
:
$ RAILS_ENV=production script/delayed_job start
$ RAILS_ENV=production script/delayed_job stop
$ RAILS_ENV=production script/delayed_job -n 2 start
$ RAILS_ENV=production script/delayed_job stop
$ RAILS_ENV=production script/delayed_job --queue=tracking start
$ RAILS_ENV=production script/delayed_job --queues=mailers,tasks start
, QUEUE QUEUES.
QUEUE=tracking rake jobs:work
QUEUES=mailers,tasks rake jobs:work
Heroku, procfile, :
worker1: QUEUE=tracking rake jobs:work
worker2: QUEUES=mailers,tasks rake jobs:work
:
heroku ps:scale worker1=2 worker2=1
..