我使用Camel来路由Activemq消息。 Camel使用org.apache.camel.Main类启动,如下所示:
public class SDaemon {
private org.apache.camel.Main main;
public static void main(String[] args) throws Exception {
SDaemon sDaemon = new SDaemon();
sDaemon.boot();
}
public void boot() {
try {
main = new Main();
main.enableHangupSupport();
PooledConnectionFactory p = new PooledConnectionFactory();
p.setMaxConnections(8);
p.setMaximumActiveSessionPerConnection(500);
ActiveMQComponent comp1 = activeMQComponent("tcp://localhost:61616");
comp1.setUsePooledConnection(true);
comp1.setConnectionFactory(p.getConnectionFactory());
ActiveMQComponent comp2 = activeMQComponent("tcp://192.168.10.103:61616");
comp2.setUsePooledConnection(true);
comp2.setConnectionFactory(p.getConnectionFactory());
main.bind("activemq", comp1); //ToGet
main.bind("activemq2", comp2); //ToInOut
main.bind("activemqException", activeMQComponent("tcp://localhost:61616")); //OnException
main.addRouteBuilder(new MyRouteBuilder());
System.out.println("Starting Camel(SDaemon). Use ctrl + c to terminate the JVM.\n");
main.run();
} catch (Exception e){
e.printStackTrace();
}
}
private static class MyRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
//...
}
}
}
问题:当我发送Ctrl+C
来关闭骆驼时,会记录此警告:
Unable to register shutdown hook due to JVM state
为什么呢?以及如何解决这个问题?
答案 0 :(得分:0)
请看一下这个关于优雅地关闭驼峰的页面 - http://camel.apache.org/graceful-shutdown.html
您可以使用以下方式取消警告:
context.getShutdownStrategegy().setSuppressLoggingOnTimeout(true);