Collective Idea

Collective Idea Logo

Brian Ryckbost

The Big Three-Oh

By Brian Ryckbost on January 04, 2012 in

Delayed Job turned 3 over the holidays. It’s been a long time coming but it finally happened. A huge thanks goes out to betamatt for his contributions and help in maintaining this project over the past year, as well as bernardelli for adding named queues. Thanks guys!

Changes

Here’s a quick rundown of the changes. You can see the full list on GitHub.

  • New: Named queues [ bernardelli ]
  • New: Job/Worker lifecycle callbacks [ betamatt ]
  • Change: daemons is no longer a runtime dependency
  • Change: Active Record backend support is provided by a separate gem
  • Change: Enqueue hook is called before jobs are saved so that they may be modified
  • Fix: Problem deserializing models that use a custom primary key column
  • Fix: Deserializing AR models when the object isn’t in the default scope
  • Fix: Hooks not getting called when delay_jobs is false

DJ 3 introduces Resque-style named queues while still retaining DJ-style priority. The goal is to provide a system for grouping tasks to be worked by separate pools of workers.

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'

If you’re using rake, you can work off those queues by setting the QUEUE or QUEUES environment variable. If you’re using daemons, set the --queue or --queues option.

# with rake
$ QUEUE=tracking rake jobs:work
$ QUEUES=mailers,tasks rake jobs:work

# with daemons
$ RAILS_ENV=production delayed_job --queue=tracking start
$ RAILS_ENV=production delayed_job --queues=mailers,tasks start

DJ 3 no longer has daemons as a runtime dependency. You’ll need to add gem 'daemons' to your Gemfile if you want to use script/delayed_job. Check the comments on the commit for further explanation.

As always, feedback and patches are welcomed. :)

By Brian Ryckbost on January 04, 2012 in

Post a Comment

Contact Us

Find us on Google Maps
Collective Idea
25 West 8th Street, Suite 200
Holland, Michigan 49423 USA 42.790299-86.108415

Follow us on the Interwebs

We are currently available for medium and long term projects. Please get in touch if we can be of service.