tester01020304
tester01020304

Reputation: 25

Replace uri with property from configuration file in xml

How can I replace the uri with the text from configuration file myprops.cfg?

<route id="camel-http-proxy2">
   <from uri="jetty://http://127.0.0.1:5555/mock"/>
</route>

myprops.cfg:

myuri=http://127.0.0.1:555/mock

my try:

<route id="camel-http-proxy2">
   <from uri="jetty://${myuri}"/>
</route>

Then the camel read the uri as it is, it doesnt replace it with the value of the property.
another try:

<endpoint id="input1" uri="jetty//${myuri}"/>

<route id="camel-http-proxy2">
  <from uri="ref:input1"/>
</route>

error:

org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to validate xml org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://camel.apache.org/schema/blueprint":endpoint}'. One of '{"http://camel.apache.org/schema/blueprint":route}' is expected.

Upvotes: 1

Views: 241

Answers (2)

Sneharghya Pathak
Sneharghya Pathak

Reputation: 1060

You need to add the config file within the property-placeholder tag.

<cm:property-placeholder id="myblueprint.placeholder" persistent-id="myprops">

You can then reference the property as ${properties:myuri} or {{myuri}}

Upvotes: 1

tester01020304
tester01020304

Reputation: 25

The answer is:

<route id="camel-http-proxy2">
  <from uri="jetty://{{myuri}}"/>
</route>

The documentation of camel is not updated I think.

Upvotes: 1

Related Questions