スプリッターを使用して zip ファイル内のファイルを反復処理し、それに沿ってカスタム アグリゲーターも使用して、本体のリスト (メインの zip ファイル内の両方のファイル) を提供します。さて、その分割の後、アグリゲーターの結果で発生するアグリゲーション ブロック処理中にヘッダー セットを抽出したいと思います。しかし、アグリゲーターの出力が失われたようで、分割ブロックの後に何も返されません。
私はこれの基本を得ていないと確信しています。誰かがここで助けてくれれば幸いです。
<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>
アグリゲーター-
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;
}
}