Delayed_job not executing the perform method but emptying the job queue
Posted
by
James
on Stack Overflow
See other posts from Stack Overflow
or by James
Published on 2010-12-29T07:32:14Z
Indexed on
2011/01/01
17:53 UTC
Read the original article
Hit count: 269
I have a fresh rails 3 app, here's my Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.0.0' gem 'delayed_job'
gem 'sqlite3-ruby', :require => 'sqlite3'
Here's the class that represents the job that I want to queue:
class Me < Struct.new(:something)
def perform
puts "Hello from me" logger.info "Hello from me" logger.debug "Hello from me" raise Exception.new
end
end
From the console with no workers running:
irb(main):002:0> Delayed::Job.enqueue Me.new(1)
=> #<Delayed::Backend::ActiveRecord::Job id: 7, priority: 0, attempts: 0, handler: "--- !ruby/struct:Me \nsomething: 1\n", last_error: nil, run_at: "2010-12-29 07:24:11", locked_at: nil, failed_at: nil, locked_by: nil, created_at: "2010-12-29 07:24:11", updated_at: "2010-12-29 07:24:11">
Like I mentioned: there are no workers running:
irb(main):003:0> Delayed::Job.all
=> [#<Delayed::Backend::ActiveRecord::Job id: 7, priority: 0, attempts: 0, handler: "--- !ruby/struct:Me \nsomething: 1\n", last_error: nil, run_at: "2010-12-29 07:24:11", locked_at: nil, failed_at: nil, locked_by: nil, created_at: "2010-12-29 07:24:11", updated_at: "2010-12-29 07:24:11">]
I start a worker with script/delayed_job run
The queue gets emptied:
irb(main):006:0> Delayed::Job.all
=> []
However, nothing happens as a result of the puts
, nothing is logged from the logger
calls, and no exception is raised. I'd appreciate any help / insight or anything to try.
© Stack Overflow or respective owner