We have a requirement to set the toD() endpoint of load balancer dynamically in a Camel Route using Java DSL:
from("direct:start").process(urlProcessor)
.loadBalance().roundRobin()
.toD("${exchangeProperty.dynamicUrls}").end()
.log("success")
We are preparing the list of dynamicUrls strings in urlProcessor and setting it in exchange property as below:
List<String> urls = new ArrayList<>();
urls.add("http://localhost:7001/abc");
urls.add("http://localhost:7002/abc");
exchange.setProperty("dynamicUrls", urls);
Somehow this is not working as expected and dynamicUrls is not getting evaluated at the toD() endpoint.
I have tried googling a lot but not a single example clearly mentions how to achieve this requirement. Request to kindly suggest the way forward.