使用SpringXML动态重新加载CamelContext

时间:2015-12-04 19:04:22

标签: apache-camel

从SpringXML加载整个Camel上下文(而不是动态重新加载路由)是一个好习惯。以下代码片段似乎从文件系统加载更新的camel上下文(基于FileWatch服务)。这是推荐的吗?

// Detect file modification... 

camelContext.stop();
camelContext.destroy();
((AbstractApplicationContext)applicationContext).close();

SpringCamelContext.setNoStart(true);
applicationContext = new ClassPathXmlApplicationContext(
   new String[]{CAMEL_CONTEXT_FILE});
camelContext = (SpringCamelContext) applicationContext.getBean("foo-cc");
camelContext.start();

1 个答案:

答案 0 :(得分:0)

在我看来,在开发过程中可能会遇到一些问题。这样就可以重新加载不仅仅是路由,因为Spring bean和配置将被重新加载。现在,无论是否推荐,都取决于你想要完成什么以及在什么环境中完成。

相关问题