【问题标题】:GAE ImagesService().getServingUrl() is to long executed. JavaGAE ImagesService().getServingUrl() 执行时间长。爪哇
【发布时间】:2012-10-02 17:32:23
【问题描述】:

我想为 blobstore 文件创建缩略图。 我使用代码:

String servingUrl = ImagesServiceFactory.getImagesService().getServingUrl( ServingUrlOptions.Builder.withBlobKey(new BlobKey(blobKey)) .imageSize(100) .secureUrl(假) );

它工作正常。但是,当我需要为每个请求创建多个 thums 时,我会遇到异常:

com.google.apphosting.api.DeadlineExceededException: This request (2b0af6acab1f5e18) started at 2012/10/11 21:53:57.444 UTC and was still executing at 2012/10/11 21:54:57.017 UTC.

也许有人可以解决这个问题。请帮忙!

【问题讨论】:

标签: java google-app-engine thumbnails


【解决方案1】:

任务队列是为像这样长时间运行的任务设计的,你应该看看它。

https://developers.google.com/appengine/docs/java/taskqueue/overview?hl=en

【讨论】:

  • 好的。还有人质疑我是否使用此代码 - String servingUrl = ImagesServiceFactory.getImagesService().getServingUrl( ServingUrlOptions.Builder.withBlobKey(new BlobKey(blobKey)) .imageSize(100) .secureUrl(false) ); - 两次,第二次通话会更快?
  • 我不明白为什么第二次会更快。
  • 那我为什么要使用长时间运行的任务呢?我需要创建包含许多小图像的页面。但我可以t because method getServingUrl get long time. The method getServingUrl I understand how - "give me ulr for thumbs and no more". When thumbs will be created I dont 知道,但我认为不是每次调用方法 getServingUrl(可能永远不会)。
  • 调用 getServingUrl() 一次(在任务队列中),并将 url 缓存在某处(即数据存储区)。对于需要图像的所有请求,您可以使用数据存储中的 url,而不是通过 getServingUrl()。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-27
  • 2011-11-21
  • 1970-01-01
  • 1970-01-01
  • 2014-05-29
  • 2011-05-20
相关资源
最近更新 更多