开发者

Use beanstalkd, for periodic tasks, how to always make a job replaced by its latest one?

开发者 https://www.devze.com 2023-01-19 10:35 出处:网络
I am trying to use beanstalk for queuing a large number of periodic tasks (for example, tasks n开发者_如何学JAVAeed processed every N minutes), for each

I am trying to use beanstalk for queuing a large number of periodic tasks (for example, tasks n开发者_如何学JAVAeed processed every N minutes), for each task, if the last queued job is not completed (not reserved, i mean) when current job to be added, the last queued job should be replaced with current job, in other words, only the latest queued job of a task should be processed.

how can i achieve that using beanstalk?

Ideas i have got right now is: for each task, use memcached store its latest timestamps (set this when add jobs to queue), every time the worker reserved a job successfully, it first checks timestamps for this task in memcached, if timestamps of the job is same as timestamps in memcached, then process this job, otherwise skip this job, and delete it from the queue.

So is there better ways to do such work? please give your suggestions, thanks.


I found a memcache/beanstalk combination also the best solution for an implementation where I didnt want a newer but identical job entering a queue.


Until 'named jobs' are done and the software released, that may be one of the better solutions.

0

精彩评论

暂无评论...
验证码 换一张
取 消