Routing files conditionally to different file paths - 7.3

Dynamic Router (Mediation)

Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
Talend Studio
Data Governance > Third-party systems > Routing components (Mediation) > Dynamic Router components (Mediation)
Data Quality and Preparation > Third-party systems > Routing components (Mediation) > Dynamic Router components (Mediation)
Design and Development > Third-party systems > Routing components (Mediation) > Dynamic Router components (Mediation)
Last publication date

This scenario applies only to Talend Open Studio for ESB, 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, three file messages containing people information are routed to different endpoints according to the city names they contain.

The following is an extract of the example XML files used in this use case:







A predefined JavaBean, setDynaURI, is called in this use case to return endpoint URIs according to the city name contained in each message, so that the message containing the city name Washington will be routed to endpoint Washington and so forth.

For more information about creating and using JavaBeans, see Talend Studio User Guide.

package beans;

import org.apache.camel.Exchange;
import org.apache.camel.Header;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class setDynaURI {

 public String setURI(Document document,
      @Header(Exchange.SLIP_ENDPOINT) String previous) {
     return null;
  NodeList cities = document.getDocumentElement().getElementsByTagName(
  Element city = (Element) cities.item(0);
  String textContent = city.getTextContent();
   return "direct:"+textContent;