May 18, 2012

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 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:


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.


No comments:

Post a Comment