The following code works fine in the dev environment. The GET for "/ _ah / api / worker / v1 / tasks" calls the refresh () method, which adds the task to the default job queue in which POSTs processes "/ _ah / api / worker / v1 / tasks", which is processed by handle ( )
@Api(name = "worker", version = "v1", scopes = { Constants.EMAIL_SCOPE }, clientIds = { Constants.API_EXPLORER_CLIENT_ID, Constants.WEB_CLIENT_ID }) public class WorkerApi { @ApiMethod( name="refresh", path = "tasks", httpMethod = HttpMethod.GET) public void refresh() { MyObject myObject = new MyObject() Queue queue = QueueFactory.getDefaultQueue(); TaskOptions o = TaskOptions.Builder.withUrl("/_ah/api/worker/v1/tasks"); o.payload(ApiHelper.ObjectToJson(myObject )); queue.add(o); } @ApiMethod( name="handle", path = "tasks", httpMethod = HttpMethod.POST) public void handle(HttpServletRequest req, MyObject myObject) {
Unfortunately, when deployed to a real Google App Engine application, the handle method is never called into the task queue.
Interestingly, I can successfully call the handler manually using the API API, which creates the following log in the GAE console:
2014-11-24 12:01:30.914 /_ah/spi/my.test.application.WorkerApi.handle 200 1394ms 0kb Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.65 Safari/537.36 module=default version=1 198.66.21.14 - - [24/Nov/2014:12:01:30 -0800] "POST /_ah/spi/my.test.application.WorkerApi.handle HTTP/1.1" 200 116 - "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.65 Safari/537.36" "my-test-application.appspot.com" ms=1394 cpu_ms=1003 cpm_usd=0.000013 app_engine_release=1.9.16 instance=00c61b117c39338c333cff447edea78fa0f90d
But when you call the task queue, 404 always returns, creating the following log in the GAE console:
2014-11-24 12:07:54.727 /_ah/api/worker/v1/tasks 404 147ms 0kb AppEngine-Google; (+http://code.google.com/appengine) module=default version=1 0.1.0.2 - - [24/Nov/2014:12:07:54 -0800] "POST /_ah/api/worker/v1/tasks HTTP/1.1" 404 234 "https://my-test-application.appspot.com/_ah/spi/my.test.application.WorkerApi.refresh" "AppEngine-Google; (+http://code.google.com/appengine)" "my-test-application.appspot.com" ms=148 cpu_ms=23 cpm_usd=0.000026 queue_name=default task_name=9271899958322278984 pending_ms=61 app_engine_release=1.9.16 instance=00c61b117c7544e23aeb8d8b0c996da6d286d539
Again, everything works as expected in the dev environment. Deployment failed in GAE. What am I doing wrong?
Comparing the log entries, I thought I found the problem and changed the code to:
TaskOptions o = TaskOptions.Builder.withUrl("/_ah/spi/my.test.application.WorkerApi.handle");
Nope. This does not work. Now it is broken in dev environment and in GAE deployment.
Log from dev environment:
[INFO] INFO: Web hook at http:
Login from GAE console:
2014-11-24 12:24:10.872 /_ah/spi/my.test.application.WorkerApi.handle 404 396ms 0kb AppEngine-Google; (+http://code.google.com/appengine) module=default version=1 0.1.0.2 - - [24/Nov/2014:12:24:10 -0800] "POST /_ah/spi/my.test.application.WorkerApi.handle HTTP/1.1" 404 96 "https://my-test-application.appspot.com/_ah/spi/my.test.application.WorkerApi.refresh" "AppEngine-Google; (+http://code.google.com/appengine)" "my-test-application.appspot.com" ms=397 cpu_ms=23 cpm_usd=0.000011 queue_name=default task_name=7132899958322278984 app_engine_release=1.9.16 instance=00c61b117c565c0a8aa81e1b86e50d78f0346330
By the way, I am using the GAE SDK 1.9.16.