简体   繁体   English

任务队列java

[英]Task queue java

Hi i'm new to Task queue concepts when i referred the guide I got struck on this line 嗨,我是新手任务队列概念,当我提到我在这条线上被击中的指南

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

what is TaskOptions() method. 什么是TaskOptions()方法。 Is it default method are method created manually what will TaskOptions() method will return. 是否默认方法是手动创建的方法, TaskOptions()方法将返回什么。

I created a method called TaskOption() when i to return a string value its saying error as "The method url(String) is undefined for the type String" 我创建了一个名为TaskOption()的方法,当我返回一个字符串值时,它的错误为"The method url(String) is undefined for the type String"

In url what i want to specify servlet are any other. 在url中我想要指定的servlet是任何其他的。

My doubt may be stupid but please clarify it. 我怀疑可能是愚蠢的,但请澄清一下。

Thank you, sharun. 谢谢,谢伦。

It looks like a bug in the doco to me. 它看起来像是我的doco中的一个bug。 My guess is what they meant was to use TaskOptions.Builder which is a class full of static methods to make it easy to create TaskOptions. 我猜他们的意思是使用TaskOptions.Builder这是一个充满静态方法的类,可以很容易地创建TaskOptions。 So the code example should probably look like this: 所以代码示例应该如下所示:

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

Check your imports. 检查你的进口。 You may be importing the incorrect Queue class. 您可能正在导入不正确的Queue类。

If your Queue is imported via 如果您的队列是通过导入的

import com.google.appengine.api.labs.taskqueue.Queue;

then queue.add(TaskOptions.Builder.url("")) method exists. 然后存在queue.add(TaskOptions.Builder.url(""))方法。

If your Queue is imported via 如果您的队列是通过导入的

import com.google.appengine.api.taskqueue.Queue;

then will you will receive the error. 那么你会收到错误吗?

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

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