rails-activejob

How do I schedule recurring jobs in Active Job (Rails 4.2)?

微笑、不失礼 提交于 2019-11-29 02:50:20
I found this Schedule one-time jobs in Rails but this only shows how schedule one-time. I am interested in scheduling a recurring job. Delayed_job has this self.delay(:run_at => 1.minute.from_now) How do I do something like that in Rails 4.2/Active Job? omencat Similar to rab3's answer, since ActiveJob has support for callbacks, I was thinking of doing something like class MyJob < ActiveJob::Base after_perform do |job| # invoke another job at your time of choice self.class.set(:wait => 10.minutes).perform_later(job.arguments.first) end def perform(the_argument) # do your thing end end

How do I schedule recurring jobs in Active Job (Rails 4.2)?

爱⌒轻易说出口 提交于 2019-11-27 17:06:36
问题 I found this Schedule one-time jobs in Rails but this only shows how schedule one-time. I am interested in scheduling a recurring job. Delayed_job has this self.delay(:run_at => 1.minute.from_now) How do I do something like that in Rails 4.2/Active Job? 回答1: Similar to rab3's answer, since ActiveJob has support for callbacks, I was thinking of doing something like class MyJob < ActiveJob::Base after_perform do |job| # invoke another job at your time of choice self.class.set(:wait => 10