coolD
coolD

Reputation: 79

How to add dynamic value to camel 'To' endpoint url?

I need to add a dynamically changing value to camel 'to' endpoint url as below.

from("direct:getNewData")
   .process(new Processor() {
            public void process(Exchange exchange) throws Exception {
            }})
.to("http://dummyhost/12345");

How am I pass and set 12345 value to change dynamically in route endpoint url from java service?

Upvotes: 3

Views: 3286

Answers (1)

Ben ODay
Ben ODay

Reputation: 21015

I generally just use a simple expression with the recipient list pattern...with this its easy to dynamically construct a URI based on a message header value...

from("direct:getNewData")
.recipientList(simple("http://dummyhost/${header.foo}"));

Upvotes: 4

Related Questions