在触发任务期间AppEngine超时

时间:2015-01-27 19:55:24

标签: java google-app-engine asynchronous

这种情况过去常常会持续几个月:(曾经发生过的事情)
 1. API调用,限制为60秒
 2.我通过任务异步运行一些Endpoint API调用,所以我返回一个等待'消息,指示呼叫者稍后重试
 这项任务被解雇了  4. API调用返回'等等  5.任务继续运行

现在发生了什么:
 这项任务被解雇了 2. API NOT 返回
 3.任务继续进行  4. API调用超时

这是我使用的代码:
1)'常规' API调用(60秒时间限制)

      AsynchronousFire(operation, parameter);  

2)AsynchronousFire

 @Override public void AsynchronousFire(Operation operation, Parameters parameter) {
    Queue queue = QueueFactory.getQueue("asynchronous-command");
    byte[] bytes = ObjectSerializer.Serialize(parameter);
    String bytesMD5 = ObjectSerializer.getMD5(bytes);
    String userMD5 = ObjectSerializer.getMD5(parameter.getEmail().getBytes());
    String taskName = userMD5 + bytesMD5;
    if (this.executingTasksNames.containsKey(taskName)) {
      logger.warning("Task already exists --- Operation:" + operation + " taskName: " + taskName);
    } else {
      String encodedBytes = Base64.encodeBase64String(bytes);
      TaskOptions taskOptions = TaskOptions.Builder.withUrl("/asynchronous_dispatch_command").
          param("taskName", taskName).
          param("operation", operation.toString()).
          param("parameters", encodedBytes);
      taskOptions.countdownMillis(0);
      TaskHandle taskHandle = queue.add(taskOptions);
      this.executingTasksNames.put(taskName, taskHandle.getName());
    }
  }

3)HTTP Servlet:asynchronous_dispatch_command

public class AsynchronousDispatchCommand extends HttpServlet {

  @Override public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String operationName = request.getParameter("operation");
    String parametersEncoded = request.getParameter("parameters");
    byte[] parametersBytes = Base64.decodeBase64(parametersEncoded);
    Operation operation = Operation.fromString(operationName);
    Parameters parameters = (Parameters) ObjectSerializer.Deserialize(parametersBytes);
    controller.AsynchronousDispatch(request, operation, parameters, response);
  }
}

一个。这段代码是否正确?
 湾这曾经可靠地工作。在过去的两个月中发生了什么破坏了它?  C。有没有办法让这种机制可靠地运作?

由于

0 个答案:

没有答案