Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Read Apache Camel Configuration from a Property file


Requirement is to read Camel configuration like route uri value from a Property File. If the property file is available in camel context then it can be used to dynamic routes, endpoint, uri values etc.
Camel provides propertyPlaceHolder to load property file from classpath.



Here ${env} is declared as a -D option in server config as -Denv=preprod.Property file preprod.properties has a URI entry for bean endpoint as endpoint.bean = bean:testBean. Camel context could access this property with following syntax:


Using Camel with Spring is a common practice and property file can be loaded with the help of Spring's propertyPlaceHolder but using it with is tricky. Spring's property placeHolder to load the file:

class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">


There are two ways to use it with camel.But first I would change the property value to endpoint.bean=testBean and do mention endpoint type in route.


Another way to achieve it, is.








This post first appeared on My Interpretations, please read the originial post: here

Share the post

Read Apache Camel Configuration from a Property file

×

Subscribe to My Interpretations

Get updates delivered right to your inbox!

Thank you for your subscription

×