karavan-demo/aggregator/Aggregator.java (18 lines of code) (raw):

import org.apache.camel.BindToRegistry; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.Exchange; import org.apache.camel.AggregationStrategy; import java.util.ArrayList; @BindToRegistry("aggregator") public class Aggregator implements AggregationStrategy { public Exchange aggregate(Exchange oldExchange, Exchange newExchange) { if (oldExchange == null) { return newExchange; } String oldBody = oldExchange.getIn().getBody(String.class); String newBody = newExchange.getIn().getBody(String.class); oldExchange.getIn().setBody(oldBody + "+" + newBody); return oldExchange; } }