0

I have a processor with below code

ProducerTemplate.sendBodyAndProperty("direct:endpoint", body, property, propertyValue) 

I need to use propertyValue in the below route()

<route>
    <from uri="direct:endpoint" />
    <to uri="file:/?fileName=${propertyValue}" />
</route>

Please advice

rocky
  • 753
  • 2
  • 10
  • 26
  • related to https://stackoverflow.com/questions/41712421/how-to-retrieve-a-exchange-property-in-the-camel-route-xml – M.Ricciuti Oct 25 '18 at 19:06

2 Answers2

0

With the producer method sendBodyAndProperty you are setting an exchange property : so you can simply use Exchange Property EL in your route definition.

Assuming your property key is "targetFileName", you can write:

<route>
    <from uri="direct:endpoint" />
    <to uri="file:/?fileName=${exchangeProperty.targetFileName}" />
</route>
M.Ricciuti
  • 11,070
  • 2
  • 34
  • 54
  • thank you for your help!!! dynamic uri cannot be framed using component. so i tried with recipientlist. like below recipientList(simple("file:/?fileName=${exchangeProperty.targetFileName}")); – rocky Oct 26 '18 at 06:54
  • strange.. I made a test with Java DSL and Camel version 2.22.0, it's working fine: `to("file:/?fileName=${exchangeProperty.targetFileName}")`. Did it work with recipientlist ? – M.Ricciuti Oct 26 '18 at 06:57
  • Could not resolve placeholder 'exchangeProperty.signFileName' in string value "file:encrypt/destination?fileName=${exchangeProperty.signFileName}" – rocky Oct 26 '18 at 07:02
0

After making below change it worked like charm..thank you @M.Ricciuti

.to("file:?fileName=$simple{exchangeProperty.targetFileName}") 
rocky
  • 753
  • 2
  • 10
  • 26