I'd like to split exchange message body (it's list of MyCustomClass object), process them (one by one) and them aggregate the all exchanges together. Split is ok, process one by one also ok, but I can't figure out how to aggregate them.
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
})
I don't need complicated aggregation, just collect list of splitted Exchanges and handle them in the final processor.
write like this
.aggregate(new AggregationStrategy() {
@Override
public Exchange aggregate(Exchange exchange, Exchange exchange1) {
//logic for aggregation using exchnage and exchange1
}
})