2
我們使用分隔符來遍歷壓縮文件中的文件,並且還使用了一個自定義聚合器,它爲我們提供了主體壓縮文件中的兩個文件的主體列表。現在,在分割之後,我想提取在聚合塊處理過程中發生在聚合器結果上的標頭集。但是,聚合器的輸出似乎丟失了,在拆分塊之後我沒有收到任何迴應。Apache Camel:獲取聚合器的響應?
我相信我沒有得到這個基礎知識。如果有人可以在這裏幫助,將不勝感激。
<route id="main-route">
<split streaming="true">
<ref>zipSplitter</ref>
<choice>
<when>
<method bean="fileHandler" method="isY" />
<to uri="direct:y" />
</when>
<otherwise>
<to uri="direct:x" />
</otherwise>
</choice>
<to uri="direct:aggregate" />
</split>
<!--Do something by extracting the headers set during the processing underneath in the aggregation block i.e. process-data -->
</route>
<route id="aggregate-data">
<from uri="direct:aggregate" />
<camel:aggregate strategyRef="aggregationStrategy" completionSize="2">
<camel:correlationExpression>
<constant>true</constant>
</camel:correlationExpression>
<to uri="direct:process-data"/>
</camel:aggregate>
</route>
Aggregator-
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
Object newBody = newExchange.getIn().getBody();
Map<String, Object> newHeaders = newExchange.getIn().getHeaders();
ArrayList<Object> list = null;
if (oldExchange == null) {
list = new ArrayList<Object>();
list.add(newBody);
newExchange.getIn().setBody(list);
return newExchange;
} else {
Map<String, Object> olderHeaders = oldExchange.getIn().getHeaders();
olderHeaders.putAll(newHeaders);
list = oldExchange.getIn().getBody(ArrayList.class);
list.add(newBody);
return oldExchange;
}
}