简体   繁体   English

任务队列Java API

[英]Task Queue Java API

Hi when i started to work on Task queue concept i got struck on this line 嗨,当我开始研究“任务队列”概念时,我被这条线打中了

 queue.add(
  DatastoreServiceFactory.getDatastoreService().getCurrentTransaction(),
  TaskOptions().url("/path/to/my/worker"));

What will DatastoreServiceFactory do... How to redirect this page to another servlet.... in the url i gave .url("/myservlet") but it doesn't redirected to servlet Please say what should given in .url.Help me. DatastoreServiceFactory会做什么...如何将页面重定向到另一个servlet...。在我给.url(“ / myservlet”)的url中,但没有将其重定向到servlet请说出.url.Help中应该给出的内容我。

Regards, sharun 问候,莎朗

in your example, the DatastoreServiceFactory.getDatastoreService().getCurrentTransaction() argument is used to attach a task to the current datastore transaction. 在您的示例中, DatastoreServiceFactory.getDatastoreService().getCurrentTransaction()参数用于将任务附加到当前数据存储事务。 if you provide that argument, the task will be added if and only if the datastore transaction commits. 如果提供该参数,则仅在数据存储事务提交时才添加任务。

in your case, the task probably isn't executing your servlet because you don't commit the datastore transaction. 在您的情况下,该任务可能没有执行servlet,因为您没有提交数据存储事务。 remove the transaction parameter entirely and just try this instead: 完全删除transaction参数,而只需尝试以下方法:

queue.add(TaskOptions().url("/path/to/my/worker"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM