【发布时间】:2014-03-20 17:52:05
【问题描述】:
我有一个要运行的 cron 作业,它使用我的 Cloud Datastore 中的实体来计算受欢迎程度。
实体摘录:
@Entity
public class Theme {
@Id
private String themeID;
public int popularity;
public void setPopularity(int popularity) {
this.popularity = popularity;
}
在我的 CronController 中:
@SuppressWarnings("serial")
public class CronController extends HttpServlet {
private static final Logger _logger = Logger.getLogger(CronController.class.getName());
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
try {
_logger.info("Cron Job has been executed");
EntityManager mgr = getEntityManager();
Theme theme = null;
theme = mgr.find(Theme.class, "101");
theme.setPopularity(3);
}
catch (Exception ex) {
//Log any exceptions in your Cron Job
_logger.info("error");
}
}
我知道 cron 作业按要求运行,因为如果我将“101”更改为(长)101,它将无法说明日志中需要字符串,但是如果按上述方式编码,则日志文件会显示以下内容:
0.1.0.1 - - [19/Feb/2014:17:38:37 -0800] "GET /cron/popularity HTTP/1.1" 200 0 - "AppEngine-Google; (+http://code.google.com/appengine)" "themeviewer.appspot.com" ms=14 cpu_ms=233 queue_name=__cron task_name=243a771773a2bbc80eed32256a5b5043 app_engine_release=1.9.0 instance=00c61b117cabbfbf9dcbf5dedbeb449cc73567
我不知道如何让它记录一个错误来告诉我为什么实体“101”在这个 cron 作业运行后没有流行值 3。我该如何调试?
顺便说一句,日志文件也没有显示“Cron Job 已执行”...我正在使用以下网站作为教程 here
【问题讨论】:
标签: android entity-framework google-app-engine cron cron-task