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. I'm using Java DSL.
2
votes
1 Answers
4
votes
Camel has extensive properties support.
At the very simple case you can do the following:
PropertiesComponent pc = new PropertiesComponent();
pc.setLocation("classpath:com/mycompany/myprop.properties");
context.addComponent("properties", pc);
myprop.properties:
route.start=file:///tmp/myfile
route.to=direct:whatever
And in your route you can use the {{..}} placeholder syntax to refer to properties.
from("{{route.start}}")
.split()
.process(whatever)
.to("{{route.to}}")
If you're using spring and your properties file is loaded already you can skip the properties component definition and refer to properties directly.
Read the documentation for more info.