I am giving resque a try, but not sure about resque worker instance’s lifecyle. Lets say I have the task set up the following way:
class User
def self.start_job(str)
Resque.enqueue(Job, str)
end
end
and
class Job
def self.perform(str)
Message.create(:user => str.split(" ")[0],
:message => str.split(" ")[1])
end
end
After the Message is created, there is after_create hook which calls another long running task:
class Message < ActiveRecord::Base
after_create (or after_commit) :do_a_ridiculous_long_task
def do_a_ridiculous_long_task
do_something
end
end
Does resque worker’s lifecycle end right after the message is created, or does it continue until after after_create method in Message model is finished? In other terms, how far does resque worker trail along with the ActiveRecord object’s lifecycle?
Turns out that resque worker is not responsible for after_create events it will trigger. Those events will be passed on to rails instance.
Here is the answer: https://github.com/defunkt/resque/issues/483#issuecomment-3396215