How can properties files be used with Apache Camel to refer to configurable properties For example, if there's a route that reads files from a folder, how can that folder location be configured in a properties file. Using Spring DSL
2
votes
2 Answers
1
votes
Please refer to this link
You can configure properties file, the standard way in spring using
context:property-placeholder
Then use the properties with $ notation. Just refer the caveat in above link. You'll need to create an endpoint using the property and then use that in your route.
0
votes
You can use Camel's Properties component for this.
First, add a line like this to your Spring XML, to initialise the Properties component bean:
<bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent"
<property name="location" value="classpath:application.properties"/>
</bean>
Then create a file in your classpath (e.g. src/main/resources/application.properties) containing your properties, like this:
your.directory.name=home
another.value=foo
Then to reference these properties in a Camel route, just use the property name, surrounded by twin braces, e.g.:
<from uri="file:src/{{your.directory.name}}?noop=true"/>
<to ... />