How to set targeted Modules for specific URL in AppEngine + Java

核能气质少年 提交于 2019-12-11 14:57:22

问题


In Backends base app engine project(Java) i was doing

Queue queue = QueueFactory.getQueue("userou-queue");
TaskOptions objTskOptions = TaskOptions.Builder.withUrl("/backendsURL/")
.countdownMillis(2000)
.header("Host", BackendServiceFactory.getBackendService().getBackendAddress("backendname"))
.method(Method.GET);
queue.add(objTskOptions);

But now for Modules How can i target a specific Module for my specific URL.

Please help me.


回答1:


From App Engine documentation:

The following code sample demonstrates how to create a push task addressed to instance 1 of a module named backend1, using the target directive:

import com.google.appengine.api.taskqueue.Queue;
import com.google.appengine.api.taskqueue.QueueFactory; 
import static com.google.appengine.api.taskqueue.TaskOptions.Builder.*;
import com.google.appengine.api.backends.*;

// ...
queue.add(withUrl("/path/to/my/worker").param("key", key).header("Host",
BackendServiceFactory.getBackendService().getBackendAddress("backend1", 1));



回答2:


Define the target parameter in the queue definition file: https://cloud.google.com/appengine/docs/java/config/queue#target



来源:https://stackoverflow.com/questions/27009501/how-to-set-targeted-modules-for-specific-url-in-appengine-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!