2014-12-05 62 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