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.
精彩评论