Delayed Job propose to store it in default database.
Delayed::Job.all
And you know it's API very well
A great benefit to build
your own features on top of it
failed_jobs = Delayed::Job.
where(:queue => "toxic").
where("last_failed_at is not null")
if failed_jobs.any?
Mail.new(
:subject => failed_jobs.count.to_s +
"in enterprise queue now",
:body => "..."
).deliver
end
I've spend 20 minutes on building this feature
starting from zero knowledge about DJ
DJ supports any document or relational database
Using Redis will have problems
Because DJ was originally designed with using relation database features
Resque: must use redis
Which gives you a power of being modern
and troll your friends that still not using it.
The true benefit of Redis over RDBMS
is that it is 100 times faster
In real world example is Ecommerce site:
6 purchases per second
5 large instances running jobs
7 seconds per job
Resque can process
But DJ can not
But you will pay a lot for
being that fast and that cool
Redis hates ActiveRecord
class User < AR::Base
after_create :fetch_linkedin_profile
def fetch_linkedin_profile
Resque.enqueue(
FetchLinkedinProfile, id
)
end
end
class FetchLinkedinProfile
def self.perform(user_id)
user = User.find(user_id)
end
end
How it look like from IO standpoint
Web Server Process
BEGIN
INSERT INTO `users`
RPUSH resque:queue:low
---
---
---
COMMIT
Worker Process
---
---
---
LPOP resque:queue:low
SELECT * FROM users WHERE id = ?
=>AR::RecordNotFound
require 'ar_after_transaction'
require 'resque'
Resque.class_eval do
class << self
alias_method
:enqueue_without_transaction,
:enqueue
def enqueue(*args)
ActiveRecord::Base.
after_transaction do
enqueue_without_transaction(*args)
end
end
end
end