Splitting a message and renaming the sub-messages according to contained information

SetHeader - Mediation

Talend Documentation Team
Talend Data Services Platform
Talend Data Fabric
Talend MDM Platform
Talend Real-Time Big Data Platform
Talend Open Studio for ESB
Talend ESB
Data Governance > Third-party systems > Processing components (Mediation) > SetHeader components (Mediation)
Design and Development > Third-party systems > Processing components (Mediation) > SetHeader components (Mediation)
Data Quality and Preparation > Third-party systems > Processing components (Mediation) > SetHeader components (Mediation)
Talend Studio

This scenario applies only to Talend Open Studio for ESB, Talend Data Services Platform and Talend Data Fabric.

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

In this scenario, a file message containing people information is split into sub-messages. Each sub-messages is renamed according the city name it contains, and then routed to another endpoint.

The following is the example XML file used in this use case:


A predefined Java Bean, setFileNames, is called by the cSetHeader component used in this use case to define a file name for each message according to the city name it contains. For more information about creating and using Java Beans, see Talend Studio User Guide.

package beans;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class setFileNames {
	public String getCityName(Document document) {
		NodeList cities = document.getDocumentElement().getElementsByTagName(
		Element city = (Element) cities.item(0);
		String textContent = city.getTextContent();
			return textContent+".xml";