Set dynamically two or more http urls in TO endpoint of load balancer in round-robin mode

34 Views Asked by At

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.

0

There are 0 best solutions below