java - Guaranteeing that a task is added to push queue only once in GAE -


i want ensure task — task operates on single entity — gets added push queue at-most-once, till such time added task finished. should able add same task — same entity — again.

a simple example task updates entity a. want able to:

  1. add task x update entity a push queue.
  2. while task x in queue entity a, other attempts add task x entity should fail.
  3. once finished, should once again able add task x entity a.

the simple solution seems to use task name incorporates both name of task x , unique id of entity a.

however, think approach doesn't satisfy condition 3: task names "tombstoned" uncontrollable period & can't re-used till then.

from docs:

an advantage of assigning own task names named tasks de-duplicated, means can use task names guarantee* task added once. de-duplication continues 9 days after task completed or deleted.

does mean task names can't re-used 9 days?

indeed, task names can't re-used 9 days after no longer in queue. safety reason ensure traces of previous identically-named tasks flushed entire distributed infra.

you encode in task name current timestamp, rounded full second, limit actual write rate 1/s (which max average write rate same entity group anyways). if fail enqueue task (because in queue) try enqueue 1 next second (if don't have alternate way of triggering update task). encode timestamp towards end of task name, not beginning, avoid performance implications mentioned in same doc referenced.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -