2017-08-03 69 views
0


我试图想出一个办法来动态更新属性(从PropertyComponent)不停止骆驼路线: 下面是它的一个例子:重新从骆驼路由一个属性不停止

@Override 
public void configure() throws Exception { 
     CamelContext ctx = super.getContext(); 
     PropertiesComponent pc = new PropertiesComponent(); 
     pc.setLocation("/tmp/apache-deltaspike.properties"); 
     ctx.addComponent("properties", pc); 

     // Logs Hello World every 2000 milliseconds 
     from("timer://myEapTimer?fixedRate=true&period=2000") 
      .log(LoggingLevel.INFO, "com.sample.route", "{{customProperty}}") 
      .to("log:HelloWorldLog?level=INFO"); 

} 

外部属性文件包含每当Timer触发时要打印的消息。我需要找到一种方法让Route重新加载Property文件而不停止它。 顺便说一句我正在使用Apache Camel 2.17.0。 谢谢

回答

1

这是不可能的,{{xxx}}只解决一次路线启动时。

您可以使用Java bean,您可以在其中自行加载属性文件并获取值并在那里执行日志记录。

或者您可以使用bean参数绑定调用Java bean并注入属性值。但是你还需要配置属性组件以不使用缓存等。

+0

感谢您的帮助克劳斯! –