Reputation: 462
I'm trying to use the System Properties' proxy settings for the http4 component to no avail.
The documentation gives this example:
<camelContext>
<properties>
<property key="http.proxyHost" value="172.168.18.9"/>
<property key="http.proxyPort" value="8080"/>
</properties>
</camelContext>
but that's just using hardcoded values.
Is there a way to use placeholders within the camelContext properties?
Upvotes: 1
Views: 1817
Reputation: 462
First of all, you need the PropertiesComponent to resolve properties within the <camelContext>
:
<bean id="propertiesComponent" class="org.apache.camel.component.properties.PropertiesComponent" />
You don't need to specify a location, if you just need support for one of the following:
Now you can use placeholders in the camelContext properties:
<camelContext>
<properties>
<property key="http.proxyHost" value="{{http.proxyHost}}"/>
<property key="http.proxyPort" value="{{http.proxyPort}}"/>
</properties>
</camelContext>
One other thing to note is that this will fail if the system property is not set. You can (and probably should) specify a default value after a colon
<property key="http.proxyHost" value="{{http.proxyHost:}}"/>
<property key="http.proxyPort" value="{{http.proxyPort:}}"/>
to assure it works in both cases.
Upvotes: 1