Sebastian Saip
Sebastian Saip

Reputation: 462

use system properties proxy settings for camel http4

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

Answers (1)

Sebastian Saip
Sebastian Saip

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

Related Questions