2017-11-01 8 views
0

私は交換メッセージ本文(MyCustomClassオブジェクトのリスト)を分割し、それらを(1つずつ)処理し、すべての交換をまとめてまとめたいと思います。分割は大丈夫ですが、1つずつ処理しても大丈夫ですが、集計する方法はわかりません。Apache Camelの分割と集計

from("mysource") 
    .unmarshal(new ListJacksonDataFormat(MyClass.class)) 
    .split().body() 
    .process(new Processor() { 
     @Override 
     public void process(Exchange exchange) throws Exception { 
      // process MyClass item 
      exchange.getIn().setBody(processedItem); 
     } 
    }) 
    .to("destinationForProcessedItem") 
    .aggregate(new GroupedExchangeAggregationStrategy()) <== Seems like problem is here 
    .process(new Processor() { 
      // handle result of aggregation 
    }) 

複雑な集約は必要ありません。分割されたExchangeのリストを収集し、最終的なプロセッサで処理するだけです。のみスプリッタを用い例というタイトルのセクションでhttp://camel.apache.org/composed-message-processor.html:この

答えて

0

書き込みが成るメッセージプロセッサEIPパターンを参照し、内蔵アグリゲータスプリッタでの使用します。

0
  .aggregate(new AggregationStrategy() { 
       @Override 
       public Exchange aggregate(Exchange exchange, Exchange exchange1) { 
        //logic for aggregation using exchnage and exchange1 
       } 
      })