0

I have a blueprint.xml in which I write some routes for an ESB. I want to get values from an XML file passed into the route. I want to then use these values to make up a dynamic property key name and call the properties file and get the matching property (all within the route). I want to avoid having to create a Java processor due to the overhead of instantiating this each time. Essentially I want to do this:

    <from uri="file:C:/myfilelocation?"/>
    <to uri= {{<xpath>//company</xpath>+<xpath>//branch</xpath>}}/>

So in blueprint you call a property using {{}} I am trying to place the xpath values as the property key inside of the property {{}} tags. In my properties file I have a mapping for each company/branch combination like so:

company1branch1=http://thiscompany.com company2branch2=http://someothercompany.com

Any way to do this, e.g. some sort of escape characters?

user1769045
  • 141
  • 1
  • 3
  • 12

1 Answers1

0

The < to > is for static uris, if you want to use dynamic runtime computed uris, then you should use the recipient list EIP: http://camel.apache.org/recipient-list.html that allows to send a message to a recipient calculcated at runtime.

This is also describer in this FAQ: http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html

Though with the xpath, you would need to set them as headers first. Something a like:

<setHeader headerName="company">
   <xpath resultType="java.lang.String">/xxxx</xpath>
</setHeader>
...
<recipientList><simple>{{${header.company}${header.branch}}}</simple></recipientList>

Also the recipient list can send to 2+ destinations, the separator is by default comma. But you can configure that. See the links above.

Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65
  • Thaks Claus, this is good stuff to try. However, it does not work yet and I notice that when I do a log on ${header.company} it also prints out the XML tags. How do I strip these away? – user1769045 Apr 25 '13 at 14:02
  • You can specify the resultType to be a String, then it ought to strip out the tags. Or you would need to use /company/text() to tell xpath to grab only the text. – Claus Ibsen Apr 25 '13 at 15:44
  • Hi again Claus, This does not appear to be working. The xpath values are not resolving, so when wrapped with {{}} the property look up fails, as the key reads literally - ${header.company}${header.branch} Any ideas? – user1769045 Apr 25 '13 at 17:16