I just did some testing.

I didn't need to use the dispatch.yaml, I simply had a named queue that 
targets the main app module.

The code in the API then adds the Task to this named queue.

Didn't need to use a Host header in the Task options.

On Monday, November 16, 2015 at 1:51:55 PM UTC, Kurt Hartmann wrote:
>
> 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);
>     }
>     ...
> }
>
>
>
> On Monday, November 16, 2015 at 6:16:18 AM UTC-6, Paul Canning wrote:
>>
>> I have two "modules", one being the main application and the other acting 
>> as an API.
>>
>> Both use the same Cloud SQL and Storage.
>>
>> How can I, in my code, add a task, from the API, to the Push Queue and 
>> have it run code that sits in the main application module?
>>
>> Is it simply a case of adding a task to a certain queue (by name) that 
>> targets the main app?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/48c359c7-322b-4b7f-ba4a-62836ca355ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to