JavaGoogleAppEngine推送任务始终返回405
我在Google App Engine上实现了一个推送任务队列。这是我如何调用任务队列的代码
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)) ;
这是任务的代码
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();
}
但我可以在日志中看到,我的任务返回状态代码405,任务将再次执行,但在我的代码中,我将值200设置为响应代码。知道我的代码为什么不起作用吗
# 1 楼答案
医生说
您正在使用POST方法添加任务
删除对
.method(TaskOptions.Method.POST)
的调用