0
votes

I have implemented a Push Task Queue at Google App Engine. This is the code how I call the Task Queue

 Queue queue = QueueFactory.getDefaultQueue();
 queue.add(TaskOptions.Builder.withUrl("/tasks/myTask").param("myparam", Long.toString(myparam)).retryOptions(RetryOptions.Builder.withTaskRetryLimit(1)).method(TaskOptions.Method.POST)) ;

and this is the code of the Task

 protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);

        String param = req.getParameter("myparam") ;

        resp.setStatus(HttpServletResponse.SC_OK);

        resp.setContentType("text/plain");
        resp.getWriter().println("dummy");
        resp.getWriter().flush();
    }

But I can see in the logs that my Task returns the status code 405 and the Task will be executed again but in my code I set the value 200 as Response code. Any idea why my code is not working?

1

1 Answers

0
votes

The docs state

TaskOptions.Builder constructor has methods to add data as the payload of the HTTP request, and as parameters, which are added to the URL as query parameters.

Params

Do not specify params if you are using the POST method along with a payload, or if you are using the GET method and you've included a url with query parameters.

You are adding a task with a POST method.

Remove the call to .method(TaskOptions.Method.POST)