可以使用 DeferredTask 重新启动任务本身
完成任务时调用 deferSubmitTask()
private static class DeferredSubmitTask implements DeferredTask
{
@Override
public void run()
{
try
{
QueueFactory.getQueue("submitqueue").add(TaskOptions.Builder.withUrl("/tasks/submitworker").taskName("submit"));
}
catch (com.google.appengine.api.taskqueue.TaskAlreadyExistsException ex)
{
LOG.log(Level.INFO, "submit task launch failed, it is still running...");
}
}
}
public static void deferSubmitTask(long countdownMillis)
{
QueueFactory.getDefaultQueue().add(TaskOptions.Builder.withPayload(new DeferredSubmitTask()).countdownMillis(countdownMillis));
}