Of course, here it is.
public class OutgoingAggregationStrategy implements AggregationStrategy {
/**
* Aggregates the messages.
*
* @param oldExchange
* the existing aggregated message. Is <tt>null</tt> the very
* first time as there are no existing message.
* @param newExchange
* the incoming message. This is never <tt>null</tt>.
* @return the aggregated message.
*/
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
// the first time there are no existing message and therefore
// the oldExchange is null. In these cases we just return
// the newExchange
if (oldExchange == null) {
String newBody =
newExchange.getIn().getBody(String.class);
newExchange.getOut().setBody(newBody);
Map<String, Object> headers =
newExchange.getIn().getHeaders();
newExchange.getOut().setHeaders(headers);
return newExchange;
}
if (newExchange == null) {
return oldExchange;
}
// in this example we add their bodies
String oldBody = oldExchange.getIn().getBody(String.class);
String newBody = newExchange.getIn().getBody(String.class);
// the body should be the two bodies added together
String body = oldBody + System.getProperty("line.separator") +
newBody;
// update the existing message with the added body
oldExchange.getIn().setBody(body);
// and return it
return oldExchange;
}
}
Lars
--
View this message in context:
http://camel.465427.n5.nabble.com/Zipping-the-content-of-several-files-into-one-file-tp5481638p5485873.html
Sent from the Camel - Users mailing list archive at Nabble.com.