I'd like to use custom properties defined in a custom config file under $KARAF_HOME/etc/ and use those properties in my Apache Camel Java DSL route. Could someone help me with detailed steps with an example?
At Karaf end, configuration details are as shown below (file resides in $KARAF_HOME/etc directory).
Configuration File : $KARAF_HOME/etc/client.cfg
Content in the file:
dev.userID=userName@client.com
dev.password=secretPassword
Below snippet is where I'm trying to access the above props in a Camel Route using Java DSL.
from("timer:someTimer?period=10000")
.setHeader("userID",simple("${env.userID}")
.setHeader("password",simple("${env.password}")
.log("${header[userID]}")
.log("${header[password]}")
.end();
The above code is throwing an error (see below).
Caused by: org.apache.camel.language.simple.types.SimpleIllegalSyntaxException: Unknown function: env.userID at location 0
${env.userID}
*
at org.apache.camel.language.simple.SimpleExpressionParser.parseExpression(SimpleExpressionParser.java:67) ~[132:org.apache.camel.camel-core:2.24.0]
at org.apache.camel.language.simple.SimpleLanguage.createExpression(SimpleLanguage.java:196) ~[132:org.apache.camel.camel-core:2.24.0]
at org.apache.camel.language.simple.SimpleLanguage.createExpression(SimpleLanguage.java:230) ~[132:org.apache.camel.camel-core:2.24.0]
at org.apache.camel.builder.SimpleBuilder.createExpression(SimpleBuilder.java:115) ~[132:org.apache.camel.camel-core:2.24.0]
... 11 more
Please help me how to access these properties in a Camel Route (using Java DSL), the configuration (.cfg) file is present in $KARAF_HOME/etc directory. Hope my problem description is understandable.