Delayed job: How to process job sequentially (one after another)

久未见 提交于 2019-12-23 02:37:12

问题


I am running delayed job with command RAILS_ENV=production bin/delayed_job start.

i am storing jobs with below code

Delayed::Job.enqueue QrCodeGenerator.new(client,request,params[:batch_quantity].to_i)

Currently delayed job is running jobs simeltanoulsy. i want know how to run job one after another.

Thanks,


回答1:


  1. If this job is always gonna be the same job but just with different input parameters, you can just run QUEUE=myqueue rake jobs:work because that rake process will run one job at a time. You can then run another simultaneous delayed_job rake process to run other queues as a concurrent worker (if you have other jobs that needs to be processed).

  2. If the sequential jobs you are talking about however are of different jobs / class, then you can just call the other job once the first job has finished.



来源:https://stackoverflow.com/questions/34739958/delayed-job-how-to-process-job-sequentially-one-after-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!