Skip to main content
Close announcements banner

Using cSplitter to split a message and aggregate replies from sub-messages

This scenario applies only to Talend ESB, Talend Data Services Platform, Talend MDM Platform, Talend Real-Time Big Data Platform, and Talend Data Fabric.

For more technologies supported by Talend, see Talend Mediation Components.

In this scenario, the cSplitter component is used to split a message and aggregate the replies from sub-messages.

A predefined JavaBean, AppendAggregator will be called to as the strategy to aggregate the replies from sub-messages. For more information about creating and using JavaBeans, see Using Beans.

package beans;
import org.apache.camel.Exchange;
import org.apache.camel.processor.aggregate.AggregationStrategy;

public class AppendAggregator implements AggregationStrategy {

	public Exchange aggregate(Exchange oldEx, Exchange newEx) {
		if(oldEx==null){
			return newEx;
		}
		String oldBody = oldEx.getIn().getBody(String.class);
		String newBody = newEx.getIn().getBody(String.class);
		newEx.getIn().setBody(oldBody + "\n" + newBody);
		return newEx;
	}
}

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!