Spring Using Boot Properties in Apache Camel Route
Can Spring Boot properties be used in Apache Camel route? @Value works fine, but is it possible to directly place expression holders in place.
Update: I know PropertiesComponent, but it will be another config besides Applicaiton.yml which I don't like.
application.yml
sftp:
host: 10.10.128.128
user: ftpuser1
password: ftpuser1password
path: /tmp/inputfile/test1
Spring Boot Apache Camel Route:
@Value("${sftp.user}")
private String sftpUser;
@Value("${sftp.host}")
private String sftpHost;
@Value("${sftp.password}")
private String sftpPassword;
@Value("${sftp.path}")
private String sftpInPath;
from("sftp://"+sftpUser+"@"+sftpHost+sftpInPath+"?delete=true&password="+sftpPassword)
//this is working
from("sftp://${sftp.user}@${sftp.host}${sftp.path}?password=${sftp.password}")
// is this possible something like this?
+3
source to share
3 answers
You can use property placeholders ( http://camel.apache.org/properties.html ) in Camel like this:
from("sftp://{{sftp.user}}@{{sftp.host}}{{sftp.path}}?password={{sftp.password}}")
+3
source to share
Haven't tried this locally, but you can try using this by adding this property component to the camel context (maybe you need to override the camel context config). Then you can use {{file.uri}} inside the part.
PropertiesComponent pc = new PropertiesComponent();
pc.setLocation("classpath:com/mycompany/myprop.properties");
context.addComponent("properties", pc);
+1
source to share