armandino armandino - 23 days ago 5
Java Question

Dynamic to(URI) in Camel

I'd like configure a Camel route where the

to(uri)
can be specified at runtime.

I tried the following:

public class Foo extends RouteBuilder {
@Override
public void configure() {
// the URI can point to different hosts
from("direct:start").to(${someUri}");
}
}


and then

ProducerTemplate pt = camelContext.createProducerTemplate();
pt.requestBodyAndHeader("direct:start", "someUri", "http://example.com");


However the above doesn't work (Camel complains about not having a default Endpoint).

What's the best way to go about this?