Reputation: 159
I'm fairly new to Camel and I'm trying to build a Camel route that reads a file. One of the fields of the file is a date, and that date will be used to call a service with a JSON request.
Example of harcoded call:
.inOut("cxfrs:https://myserver.edu/dostuff/20180115/deals");
I figured that I can store the date in a property of the exchange, like this:
.setProperty("dynamicDate", simple("${body.myDate}"))
I'm struggling with using the property to build the address. What would be the nicer way to replace the harcoded date with the value from the JSON object?
Upvotes: 0
Views: 241
Reputation: 159
I ended up using recipientList and the "simple" language, after forcing the exchange patter to InOut (I needed to process the webserver response)
.setExchangePattern(ExchangePattern.InOut)
.recipientList( simple("cxfrs://${header.myComputedAddress}"))
Upvotes: 0
Reputation: 7005
You should be able to use (notice the D
after to
)
.toD("cxfrs:https://myserver.edu/dostuff/${exchangeProperty.dynamicDate}/deals");
or
.toD("cxfrs:https://myserver.edu/dostuff/${body.myDate}/deals");
See http://camel.apache.org/message-endpoint.html for Camel dynamic endpoints.
Upvotes: 2