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

感謝您的幫助克勞斯! –