Usage - 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

The object instance that is used to consume messages must be explicitly registered with the Camel Registry. For example, if you are using Spring you must define the bean in the Spring configuration, spring.xml ; or if you don't use Spring, by registering the bean in JNDI, as described here:

// let's populate the context with the services we need
// note that we could just use a spring.xml file to avoid this step
JndiContext context = new JndiContext();
context.bind("bye", new SayService("Good Bye!"));

CamelContext camelContext = new DefaultCamelContext(context);  

Once an endpoint has been registered, you can build Camel routes that use it to process exchanges.

// let's add a simple route
camelContext.addRoutes(new RouteBuilder() {
   public void configure() {

Note: A bean: endpoint cannot be defined as the input to the route; that is you cannot consume from it, you can only route from some inbound message endpoint to the bean endpoint as output. So consider using a direct: or queue: endpoint as the input.

You can use the createProxy() methods on ProxyHelper to create a proxy that will generate BeanExchanges and send them to any endpoint:

Endpoint endpoint = camelContext.getEndpoint("direct:hello");
ISay proxy = ProxyHelper.createProxy(endpoint, ISay.class);
String rc = proxy.say();
assertEquals("Good Bye!", rc);

And the same route using Spring DSL:

   <from uri="direct:hello">
   <to uri="bean:bye"/>