There is something interesting about Camel Routes.
Usually they are defined in the beginning and assumed to have the same endpoints. But today I had a situation when depending on the .process() execution the result endpoint had to be dynamic.
So after consulting with one of my colleagues I found the following solution:
public class CustomRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("direct:someEndpoint")
.process(exchange -> exchange.setProperty("customDestinationProperty", "customPropertyDestinationValue");)
.to(simple("${exchangeProperty.customProperty}").getText());
}
}BUT THIS DOES NOT WORK … the problem is about to()
you have to use .toD() instead.
check http://camel.apache.org/message-endpoint.html – the “Dynamic To” part.
Hope this helps you 😉


