Finally, this is what worked for my use.
Running a camel as shown below:
CamelContext camelContext = new DefaultCamelContext(); camelContext.addRoutes(new SampleRoute()); camelContext.start();
My routebuilder class:
class SampleRoute extends RouteBuilder { @Override public void configure() { try { from("direct:consumerMethod").process(new DDT()); }catch(Exception e) { e.printStackTrace(); } } }
Then I create an interface that has a sendMessage method.
public interface DDTConsumer { public String sendMessage(Object object); }
Now I implement this method to create the endpoint of this interface and send the message to the endpoint.
DDTConsumer ddt; try { ddt = new ProxyBuilder(camelContext).endpoint("direct:consumerMethod").build(DDTConsumer.class); ddt.sendMessage(msg.getValue()); } catch (Exception e) { e.printStackTrace(); }
This solved my problem and now the route is working fine. Hope this helps others as well.
source share