在 Google Appengine 文档中,它表示任务限制为 10 分钟。然而,当我运行延迟任务时,它们会在 60 秒内消失。我找不到任何地方可以提及这一点。
这是否意味着 Appengine 延迟任务限制为 60 秒,或者可能是我做错了什么?
更新:第一个任务是从请求触发的,但我没有等待它返回(无论如何我怎么可能,没有回调)。后续的 我从任务本身内部以递归方式触发。
DeferredTask df = new QuoteReader(params);
QueueFactory.getDefaultQueue().add(withPayload(df));
其中许多都可以正常工作,但对于达到 1 分钟限制的那些,我会得到 ApiProxy$ApiDeadlineExceededException
com.googlecode.objectify.cache.Pending completeAllPendingFutures: Error cleaning up pending Future: com.googlecode.objectify.cache.CachingAsyncDatastoreService$3@17f5ddc java.util.concurrent.ExecutionException: com.google.apphosting.api.ApiProxy$ApiDeadlineExceededException: The API call datastore_v3.Get() took too long to respond and was cancelled.
我注意到的另一件事是,这会影响同时发生的对该服务器的其他请求,并且会出现 DeadlineExceededException
。
最佳答案
该错误来自超过 60 秒的数据存储操作。它与任务队列的截止日期本身并没有真正的关系。您是正确的,它们是 10 分钟(请参阅 here )
但是根据 Old related issue (也许从那时起就变成了60年代)
From Google: Even though offline requests can currently live up to 10 minutes (and background instances can live forever) datastore queries can still only live for 30 seconds.
从异常看来,您的代码已完成,并且 Objectify(稍后在请求过滤器中)实际上是发生超时的地方。我建议您拆分数据操作,以便数据存储查询更快,并在必要时对数据操作使用 .now() ,以便代码中出现异常。
关于java - Appengine 延迟任务限制为 60 秒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19698787/