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

StackOverflow https://stackoverflow.com/questions/3912751

  •  29-09-2019
  •  | 
  •  

Question

I am trying to use beanstalk for queuing a large number of periodic tasks (for example, tasks need 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.

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top