具有Resque Adapter的ActiveJob(添加延迟/超时功能)

时间:2015-06-30 07:50:59

标签: ruby resque ruby-on-rails-4.2 rails-activejob resque-scheduler

我打算使用循环传递多个活动作业。 但我需要在每个数据循环中都有一个延迟/超时功能。 我的代码就像:

for s in @saved_jobs
  # ADD delay funtion for each data to pass in ActiveJob Process
  # for ex. every data will pass to background job after every 3minutes
  ActiveCallsJob.perform_later(xxx, xx, x)
end

@saved_jobs = Information from DB
ActiveCallsJob = Class name of ActiveJob

请帮忙谢谢!

1 个答案:

答案 0 :(得分:0)

很简单。您只需阅读手册:http://guides.rubyonrails.org/active_job_basics.html#enqueue-the-job

# Enqueue a job to be performed tomorrow at noon.
MyJob.set(wait_until: Date.tomorrow.noon).perform_later(record)

# Enqueue a job to be performed 1 week from now.
MyJob.set(wait: 1.week).perform_later(record)