Skip to main content

Posts

Showing posts with the label apache

How to inject multiple endpoint in SEI using Camel's @EndpointInject

By default you can inject annotation on single method of an interface like: public interface MyListener {   @EndpointInject(uri="activemq:foo.bar")     String sayHello(String name); } what if you need multiple methods like this with @EndpointInjection happening over them for each endpoint e.g.: public interface MyListener {   @EndpointInject(uri="direct:foo")     String sayHelloFoo(String name); @EndpointInject(uri="direct:bar")     String sayHelloBar(String name); } The simple solution i have working involved spring's FactoryBean implementation. It need following steps: <!-- Define route for which you need injection to happen --> <bean id="r" class="MyListener" /> <!-- Define producer template having that route  -->   <camelContext  xmlns="http://camel.apache.org/schema/spring">         <template id="producerTemplate" />         <routeBuil

Use recipientList for dynamic routes

I was writing the route in which "to" endpoint was need to be configured dynamically with the URL coming in the body. I was trying to use simple expression language (e.g. ${in.header.test} where test is the property set in the in-message header) also with header method (e.g. header(test)). The routes for the same were: from("direct:test").to("${in.header.test}"); &  from("direct:test").to(header("test"));   after literally every thing i could have. I figured out recipientlist can do the trick e.g. from("direct:test").recipientList("${in.header.test}"); &  from("direct:test").recipientList(header("test")); Hope this works for you too.