I use the following code to execute a method with delayed job:
class MyClass
def send_a_text
t = TwilioCommunicator.new
t.send_sms("+15177416150","sent at #{Time.now}")
end
handle_asynchronously :send_a_text
end
t = MyClass.new
t.send_a_text
Without delayed job, this sends me a text message 100% of the time. With delayed job, I can see that this job is queued in the database and then dequeued but the code does not appear to run. I am testing locally and here is a snippet from my development.log:
AREL (0.5ms) INSERT INTO "delayed_jobs" ("priority", "attempts", "handler", "last_error", "run_at", "locked_at", "failed_at", "locked_by", "created_at", "updated_at") VALUES (0, 0, '--- !ruby/struct:Delayed::PerformableMethod
object: !ruby/object:MyClass {}
method_name: :send_a_text_without_delay
args: []
', NULL, '2011-07-28 05:24:47.700969', NULL, NULL, NULL, '2011-07-28 05:24:47.701070', '2011-07-28 05:24:47.701070')
AREL (2.9ms) UPDATE "delayed_jobs" SET locked_at = '2011-07-28 05:24:51.191404', locked_by = 'delayed_job host:Stephen-B-Silverbergs-MacBook.local pid:3714' WHERE (id = 13 and (locked_at is null or locked_at < '2011-07-28 01:24:51.191404') and (run_at <= '2011-07-28 05:24:51.191404'))
AREL (0.3ms) DELETE FROM "delayed_jobs" WHERE ("delayed_jobs"."id" = 13)
One thing I notice is the method_name is send_a_text_without_delay instead of send_a_text but this is the only strange thing I see. Any ideas?