2013-03-17 54 views

回答

2

这个问题也问骆驼邮件列表上 http://camel.465427.n5.nabble.com/Notification-on-CamelContext-stop-tp5729300.html

有几种方法。一个像Evgeniy Dorofeev展示生命周期策略一样。 http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/spi/LifecycleStrategy.html

另一个是使用Event对象的事件通知程序,它具有比生命周期策略更多的事件。比如这个例子所示为:http://camel.apache.org/eventnotifier-to-log-details-about-all-sent-exchanges.html

如果你使用Spring或蓝图XML,那么你可以通过定义一个bean配置它们,骆驼将它捡起来作为记录在这里:http://camel.apache.org/advanced-configuration-of-camelcontext-using-spring.html

1

这是一种方法

camelContext.addLifecycleStrategy(new LifecycleStrategySupport() { 
     @Override 
     public void onContextStop(CamelContext context) { 
     } 
    }); 

看到更多的克劳斯易卜生的答案之一,他是骆驼的行动作者http://www.manning.com/ibsen/