@DynamicRouter annotation - 6.3

Talend ESB Mediation Developer Guide

Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
Design and Development
Talend ESB

You can also use the @DynamicRouter annotation, for example the example below could be written as follows. The route method would then be invoked repeatedly as the message is processed dynamically. The idea is to return the next endpoint uri where to go. Return null to indicate the end. You can return multiple endpoints if you like, just as the Routing Slip, where each endpoint is separated by a delimiter.

public class MyDynamicRouter {

    @Consume(uri = "activemq:foo")
    public String route(@XPath("/customer/id") String customerId, 
    @Header("Location") String location, Document body) {
        // query a database to find the best match of the endpoint  
        // based on the input parameters
        // return the next endpoint uri, where to go. Return null 
        // to indicate the end.