Camel idiom to route dynamically based on the value in the body of the message
Suppose you have a route like:
from("direct:start").to("http://some.endpoint/accounts/");
where message passed through direct:start
is an XML:
<payload>
<account id="1">Bob</account>
</paylo开发者_运维问答ad>
What's the idiomatic way to extract the account's id
and append it to the to
endpoint in order to send this message to http://some.endpoint/accounts/1
?
you can use the recipient list pattern to create dynamic endpoints based on Exchange data.
from("direct:start")
.recipientList(constant("http://some.endpoint/accounts/")
.append(XPathBuilder.xpath("/payload/account/@id", String.class)));
See this FAQ about dynamic to http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html
精彩评论