dubbo如何正确关闭Spring容器

查看dubbo文档,Dubbo是通过JDK的ShutdownHook来完成优雅停机的:
http://dubbo.io/User+Guide-zh.htm#UserGuide-zh-%E4%BC%98%E9%9B%85%E5%81%9C%E6%9C%BA

但能实现优雅停机的前提是,在启动时,需要指定参数-Ddubbo.shutdown.hook=true:

com.alibaba.dubbo.container.Main.main源码:

if ("true".equals(System.getProperty(SHUTDOWN_HOOK_KEY))) { Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { for (Container container : containers) { try { container.stop(); logger.info("Dubbo " + container.getClass().getSimpleName() + " stopped!"); } catch (Throwable t) { logger.error(t.getMessage(), t); } synchronized (Main.class) { running = false; Main.class.notify(); } } } }); }

http://ask.csdn.net/questions/181901

你可能感兴趣的:(dubbo如何正确关闭Spring容器)