I'm doing this very thing in my Java app.
- In the main module, you need to add a dispatch.xml file to define a mapping to your API module. In my case, the other module is called tasks.
- Below is a nnippet from my dispatch.xml showing the URL mapping to the other module called tasks
- This file will be located in the same directory as appengine-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<dispatch-entries>
...
<dispatch>
<url>*/tasks/*</url>
<module>tasks</module>
</dispatch>
</dispatch-entries>
- Then, I set up a little helper class to add a task to a push queue. Be sure to set the Host property in the header, otherwise it won't work.
- I then dependency inject the PushTaskHelper, wherever I need it and call the helper method
public class PushTaskHelper {
public static final String MODULE_WEB_TASKS_NAME = "tasks";
public static final String MODULE_WEB_TASKS_VERSION = "v1";
public void addTaskToQueue(String controllerPath) {
String url = TASKS_MODULE_CONTEXT_ROOT + controllerPath;
TaskOptions task = TaskOptions.Builder.withUrl(url).method(TaskOptions.Method.GET)
.header("Host", ModulesServiceFactory.getModulesService().getVersionHostname(MODULE_WEB_TASKS_NAME, MODULE_WEB_TASKS_VERSION));
QueueFactory.getDefaultQueue().add(task);
}
...