2014-12-05 73 views
-1

我有一個駱駝路線與onCompletion(),然後命中Processor。在這個處理器中,它從Exchange獲得一個頭,但是這個頭返回爲空。駱駝onCompletion有空標題

我知道onCompletion()運行在該特定路線的末尾,但Exchange標頭當然應該仍然有效且可用。下面的inputLocation在班級中定義較高,適用於以前的路線。

from("file://"+inputLocation+"?initialDelay=5000&delay=2000&recursive=true&delete=true") 
    .onCompletion() 
     .process(storedProcProcessor()) 
    .end() 
    .choice() 
     .when(appContext.getBean(AppPredicate.class)) 
      .log("Need to check against APP in the database for destination.") 
      .setHeader(AppConstants.INPUTLOCATION, simple(inputLocation)) 
      .process(databaseProcessor()) 
    .endChoice(); 

回答

1

我檢查:

@Override 
public void configure() { 
    from("direct:start") 
     .onCompletion() 
     .process(new Processor() { 
      @Override 
      public void process(final Exchange exchange) throws Exception { 
       LOG.info("Hello, {}", exchange.getIn().getHeader("myHeader")); 
      } 
     }) 
     .end() 
     .setHeader("myHeader").constant("World!"); 
    } 
} 

這將打印

你好,世界!

因此,標題myHeader仍在onCompletion中可用。那麼,我猜你的標題永遠不會正確設置?

+0

謝謝我現在工作。 – 2014-12-08 10:07:47