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

1.1k views Asked by At

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.

2

There are 2 answers

7
Andrei Volgin On BEST ANSWER

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));
1
Peter Knego On

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