本文介绍了如何在Google App Engine中使用模块并使用Task Queue(Java)向其添加目标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的任务超过了任务队列超过10分钟的最后期限。通过不同的文档,我发现使用模块我可以运行一个实例来处理长时间运行的任务,但最好甚至应该使用任务队列来完成。我曾经使用后端,但它们已被弃用。



我的问题是如何将模块引入到我现有的App Engine项目中,以及如何使用它们来运行长时间运行的任务



以下是一段代码:

 队列队列= QueueFactory.getQueue( myQueue中); 
TaskOptions task = TaskOptions.Builder.withUrl(/ submitworker)。method(Method.POST);
queue.add(task);

在上面的代码中,我必须做出什么修改才能使用模块添加长时间运行的任务? [submitworker是一个servlet,它是实际的长时间运行的任务]

我曾提及链接,但我无法绕过第三步:

3。将服务声明元素添加到appengine-application.xml文件中。



另外,即使我成功将模块添加到我的项目中,模块使用任务队列?

我经历了问题,但它是一个python实现,我的实现是Java。



我正在寻找一步一步的过程如何在模块中使用Target以及如何在添加到任务队列中时使用它。



即使我将长时间运行的模块目标添加到任务队列,仍然会在10分钟后终止执行,或者即使任务队列中的任务过期,它是否会完成任务?



请建议。

解决方案

模块和服务是相同的东西,它们与旧的后端类似(仍然有效,但不推荐使用)。



获取模块的基本方法有两种:


  • 创建一个EAR并部署

  • 将服务作为WAR文件独立部署(可能性很大)您现在正在对默认模块做什么)



第二个选项可能更容易,因为它只是改变您的应用-web.xml中。你可以在每个模块有一个repo或分支,或者只是一个构建过程来改变你的目标模块。



现在你的application-web.xml可能有东西像这样:

 < application> @ appId @< / application> 
<版本> @ appVersion @< / version>
< module>默认< / module>

将其改为像这样

 <应用> @ APPID @< /应用程序> 
<版本> @ appVersion @< / version>
< module>长时间运行服务< / module>
< instance-class> B1< / instance-class>
<手动缩放>
<实例> 1< / instances>
< / manual-scaling>

您将队列本身配置为定位 queue.xml中的特定模块请参阅。

I have a task that exceeds more than 10 minutes deadline of the Task Queue. Going through different documentations, I found that using modules I could run an instance that would process the long running task but preferably even that should be done using the task queue. I had used backends but they are deprecated.

My question is how do I introduce Modules into my existing App Engine Project and how do I use them to run long-running tasks?

Following is the piece of code :

Queue queue = QueueFactory.getQueue("myqueue");
TaskOptions task = TaskOptions.Builder.withUrl("/submitworker").method(Method.POST);
queue.add(task);

What changes do I have to make in the above code to add a long-running task using a module? [The "submitworker" is a servlet which is the actual long running task]

I had referred this link, but I am unable to get around with the third step:
3. Add service declaration elements to the appengine-application.xml file.

Also, even if I successfully add a module to my project, how can I target this module using Task Queue?

I had gone through this question, but it is a python implementation, my implementation is in Java.

I am looking for a step by step process on how do I use "Target" in the modules and how to use it while adding to the task queue.

Even if I add the long-running module target to the task queue, still would it terminate the execution after 10 minutes or will it complete the task even if the task in the task queue expires?

Please suggest.

解决方案

Modules and Services are the same thing, they're similar to the old backends (which still work, but are deprecated).

There are two basic ways of getting modules to work:

  • Create an EAR and deploy that
  • Deploy services independently as WAR files (which is probably what you're doing now to the default module)

The second option is probably easier, because it's just a matter of changing your application-web.xml. You could have a repo or branch per module, or just a build process that changes the module you're targeting.

Right now your application-web.xml probably has something like this:

<application>@appId@</application>
<version>@appVersion@</version>    
<module>default</module>   

change it to something like this

<application>@appId@</application>
<version>@appVersion@</version>    
<module>long-running-service</module>
<instance-class>B1</instance-class>
<manual-scaling>
    <instances>1</instances>
</manual-scaling>

You configure the queue itself to target a specific module in queue.xml See here.

这篇关于如何在Google App Engine中使用模块并使用Task Queue(Java)向其添加目标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 07:47