Java 如何在googleappengine中实现shutdownhook处理程序

Java 如何在googleappengine中实现shutdownhook处理程序,java,google-app-engine,Java,Google App Engine,如何在googleappengine中实现shutdownhook处理程序。我不明白他们的医生在这里。我需要的是,当后端由于任何原因停止时,我需要在代码中得到通知 this is my code try{ while (haveMoreWork() && !LifecycleManager.getInstance().isShuttingDown()) { process(); // this is my funct

如何在googleappengine中实现shutdownhook处理程序。我不明白他们的医生在这里。我需要的是,当后端由于任何原因停止时,我需要在代码中得到通知

this is my code
try{        
    while (haveMoreWork() &&
        !LifecycleManager.getInstance().isShuttingDown()) {
            process(); // this is my function to read all the data.if it fails because of termination.i need to be notified.
    }catch(Exception e){
        log.log(Level.SEVERE, e.getMessage(), e);
        log.severe("error occured"+e);
        log.info("failed ");
    }

您需要使用钩子而不是状态报告:

LifecycleManager.getInstance().setShutdownHook(new ShutdownHook() {
  public void shutdown() {
    // code
  }
});