3

如何在 google appengine 中实现关闭挂钩处理程序。我在这里不理解他们的文档https://developers.google.com/appengine/docs/java/backends/overview#Shutdown。我需要的是,当后端由于任何原因停止时,我需要在代码中得到通知。

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 ");
    }
4

1 回答 1

0

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

LifecycleManager.getInstance().setShutdownHook(new ShutdownHook() {
  public void shutdown() {
    // code
  }
});
于 2015-08-05T09:57:32.177 回答