2014-04-02 27 views
1

我想在骆驼聚合器中读取多个标头。像这样 - header(“h1”)和header(“h2”)。这可能吗?如何在Apache Camel Aggregator关联中加入多个标头

from(sourceQueueUrl) 
    .aggregate(header("h1") and header("h2") , new MyAggregationStrategy()) 
    .completionSize(3) 
    .closeCorrelationKeyOnCompletion(2000) 
    .log("Sending out ${body}") 
    .aggregationRepository(repository) 
    .to(sinkQueueUrl); 
+0

明白了吧!头(“h1”)。append(头(“h2”))工作正常。 – user3487839

+0

你应该把它作为答案。 – kaqqao

回答

0

明白了吧! header("h1").append(header("h2"))工作正常。

0

另一种解决方案是使一个简单的表达是这样的:

from(sourceQueueUrl) 
    .aggregate(simple("${header.h1}+${header.h2}")) 
    .aggregationStrategy(new MyAggregationStrategy()) 
    .completionSize(3) 
    .closeCorrelationKeyOnCompletion(2000) 
    .log("Sending out ${body}") 
    .aggregationRepository(repository) 
    .to(sinkQueueUrl); 

这相当于你的解决方案,但personnaly我觉得语法简单,更容易理解。