简体   繁体   English

使用JAVA GAE sdk执行DeferredTask

[英]Executing DeferredTask with JAVA GAE sdk

I'm trying to execute delayed DeferredTask in Google App Engine (JAVA). 我正在尝试在Google App Engine(JAVA)中执行延迟的DeferredTask。

So far here is what I got. 到目前为止,这就是我所得到的。

The task class itself: 任务类本身:

public class TestTask implements DeferredTask {


    @Override
    public void run() {
        System.out.print("test");
    }

}

And the execution: 和执行:

QueueFactory.getDefaultQueue().add(TaskOptions.Builder.withEtaMillis(10000).payload(new TestTask()));

When I run it on the dev server, console output show up right away when task is added to queue, and not after 10 seconds as I wanted :( 当我在开发服务器上运行它时,在将任务添加到队列时立即显示控制台输出,而不是在我想要的10秒后显示:(

The Dev Server typically handles the execution differently. 开发服务器通常以不同的方式处理执行。 This is detailed in the following section : https://developers.google.com/appengine/docs/java/taskqueue/overview-push#Java_Push_queues_and_the_development_server 以下部分对此进行了详细说明: https : //developers.google.com/appengine/docs/java/taskqueue/overview-push#Java_Push_queues_and_the_development_server

So, it is likely that some of the parameters that you are trying to specify are ignored by the dev server and the task is executed immediately. 因此,开发服务器可能会忽略您尝试指定的某些参数,并立即执行任务。 In case you do not want the task to be executed and prefer that you manually invoke it in the dev server, there is a setting to be provided for the app server as detailed in the note above. 如果您不希望执行任务,而是希望在开发服务器中手动调用该任务,则可以为应用程序服务器提供一个设置,如上面的注释中所述。

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

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