0

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.

dk14
  • 22,206
  • 4
  • 51
  • 88
yogesh
  • 463
  • 6
  • 15

2 Answers2

3

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));
Andrei Volgin
  • 40,755
  • 6
  • 49
  • 58
  • 1
    But, Backends are deprecated. And BackendServiceFactory is also deprecated. – yogesh Nov 19 '14 at 08:26
  • The [Modules API](https://cloud.google.com/appengine/docs/java/javadoc/com/google/appengine/api/modules/package-summary) provides similar capabilities. – tx802 Nov 19 '14 at 12:59
  • This is the currently recommended way to target modules from Tasks - this App Engine doc page was updated on October 27, 2014 - just three weeks ago. – Andrei Volgin Nov 19 '14 at 15:07
  • I don't think this is the right answer. I get "IllegalStateException: Tried to get local address of unknown backend". Testing now but i think ModulesService needs to be used. At least i hope, because i don't know how else to do this with Modules and task queue in the dev server. https://cloud.google.com/appengine/docs/java/modules/routing – j_walker_dev Apr 17 '15 at 12:18
  • If you cannot find your backend, it does not mean that the answer is wrong :) Anyway, try to use the queue configuration as Peter suggested. – Andrei Volgin Apr 17 '15 at 15:48
  • The question asked about Modules, which is the upgrade of Backends. This would never work for the user, because their are no backends when using modules. Changing to the ModulesService didn't work for me, but others have said it does. https://code.google.com/p/googleappengine/issues/detail?id=10954&q=label%3AComponent-TaskQueue&colspec=ID%20Type%20Component%20Status%20Stars%20Summary%20Language%20Priority%20Owner%20Log – j_walker_dev Apr 17 '15 at 16:09
  • It works for the OP. And I did say that using Peter's suggestion is a good idea. – Andrei Volgin Apr 17 '15 at 17:19
0

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

Peter Knego
  • 79,991
  • 11
  • 123
  • 154