I'm trying to figure out if I'm able to use delayed_job
. I would need the ability to add jobs to the queue within a delayed_job
perform
method. Is this possible?
views:
141answers:
2
A:
My simple test calling send_later
in a method invoked by send_later
indicates that NO, it will not work.
Jonathan Julian
2010-01-25 04:26:52
Perhaps it's just `send_later` that does not allow this. I tested in script/console.
Jonathan Julian
2010-03-15 14:59:26
A:
According to my test, they can:
model Machine
:
class Machine < ActiveRecord::Base
def perform
Delayed::Job.enqueue Secondary.create!
end
end
model Secondary
:
class Secondary < ActiveRecord::Base
def perform
logger.info("Inside secondary's perform method (WIN)")
Proof.create!
end
end
from the console:
Delayed::Job.enqueue Machine.create!
This ends up creating an instance of Proof
and logs "Inside secondary's...".
James
2010-01-25 21:14:46
My delayed job also works fine at kicking off another delayed job as part of its operation.
Larry K
2010-03-11 20:52:06