Unfortunately spring property place holder cannot replace vars in camel
context tag, there is open issue for this:
https://issues.apache.org/activemq/browse/CAMEL-1066
Not sure if there is easy solution for this, but you can add custom
processor which will encapsulate your endpoint and than expose the property
on processor to be replaced by spring's PropertyPlaceHolderConfigurer.
janstey wrote:
>
> You should be able to use a PropertyPlaceholderConfigurer [1] to load up
> the
> properties file and then use a URI like uri="${serviceOne}"
>
> [1]
> http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.html
>
> On Wed, Oct 14, 2009 at 2:25 PM, terminator_007
> <[email protected]>wrote:
>
>>
>> my application would have different property file for different
>> environments.
>> For example
>> camel-staging.properties,camel-dev.properties,camel-integration.properties.
>> All these files would have endpoints defined in them for the respective
>> environment.
>> This is a sample properties file
>> serviceOne=http://YYYYYYYYYY:8080/serviceone/subscriber
>> serviceTwo=http://ZZZZZZZZZZ:8080/servicetwo/subscriber<http://YYYYYYYYYY:8080/serviceone/subscriber%0AserviceTwo=http://ZZZZZZZZZZ:8080/servicetwo/subscriber>
>>
>> How can I refer to these properties in my camel configuration file.
>> here is my camel configuration file. I plan to get the uri for
>> serviceone,servicetwo from the properties file.
>>
>> <bean id="soapMessageCreator" class="com.SOAPMessageCreator"/>
>> <bean id="myErrorProcessor" class="com.ErrorProcessor" />
>>
>> <bean id="myDeadLetterErrorHandler"
>> class="org.apache.camel.builder.DeadLetterChannelBuilder">
>> <property name="onRedelivery" ref="myErrorProcessor"/>
>> <property name="deadLetterUri"
>> value="activemq:topic:topic.DeadLetter"/>
>> <property name="redeliveryPolicy"
>> ref="myRedeliveryPolicyConfig"/>
>> <property name="handled" value="false"/>
>> </bean>
>> <bean id="myRedeliveryPolicyConfig"
>> class="org.apache.camel.processor.RedeliveryPolicy">
>> <property name="maximumRedeliveries" value="3" />
>> <property name="redeliverDelay" value="1800"/>
>> </bean>
>> <bean id="jbossresolver"
>> class="codeandtell.camel.jboss.VFSPackageScanClassResolver"/>
>> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"
>> >
>> <!-- <package>org.apache.camel.example.jmstofile</package> -->
>> <endpoint id="serviceOne"uri="
>> http://YYYYYYYYYY:8080/serviceone/subscriber<http://yyyyyyyyyy:8080/serviceone/subscriber>
>> "/>
>> uri="http://YYYYYYYYYY:8080/serviceone/subscriber"/>
>> <endpoint id="serviceTwo"
>> uri="http://ZZZZZZZZZZ:8080/servicetwo/subscriber"/>
>>
>> <route errorHandlerRef="myDeadLetterErrorHandler">
>> <from
>>
>> uri="activemq:topic:topic.Patient?clientId=camelClient&durableSubscriptionName=patientTopicSubscriber"/>
>> <to uri="bean:soapMessageCreator"/>
>> <multicast stopOnException="false">
>> <pipeline>
>> <setHeader headerName="endpointURL">
>> <constant>serviceOne</constant>
>> </setHeader>
>> <to ref="serviceOne"/>
>> </pipeline>
>> <pipeline>
>> <setHeader headerName="endpointURL">
>> <constant>serviceTwo</constant>
>> </setHeader>
>> <to ref="serviceTwo"/>
>> </pipeline>
>> </multicast>
>>
>> </route>
>> </camelContext>
>>
>> <bean id="http" class="org.apache.camel.component.http.HttpComponent">
>> <property name="camelContext" ref="camel"/>
>> <property name="httpConnectionManager" ref="myHttpConnectionManager"/>
>> </bean>
>>
>> <bean id="myHttpConnectionManager"
>> class="org.apache.commons.httpclient.MultiThreadedHttpConnectionManager">
>> <property name="params" ref="myHttpConnectionManagerParams"/>
>> </bean>
>>
>> <bean id="myHttpConnectionManagerParams"
>> class="org.apache.commons.httpclient.params.HttpConnectionManagerParams">
>> <property name="defaultMaxConnectionsPerHost" value="5"/>
>> </bean>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/reading-endpoints-from-a-properties-file-tp25894947p25894947.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
> --
> Cheers,
> Jon
>
> http://janstey.blogspot.com/
>
>
--
View this message in context:
http://www.nabble.com/reading-endpoints-from-a-properties-file-tp25894947p25895352.html
Sent from the Camel - Users mailing list archive at Nabble.com.