我在用这个拿到文件。 文件位于主机和路径中。 它应该每分钟轮询一次。 但它走了一次,却得不到文件。 它不显示内部日志,调试无法进入进程。
from("sftp://192.168.149.11:22/home/us/POLICE_BELGE_MUTABAKAT/GUNLUK/"
+ "?"
+ "password=password"
+ "&username=username"
+ "&fileName="
+ "f1.txt"
+ "&scheduler=quartz2&scheduler.cron=0+0/1+*+*+*+?+*+?").process(new Processor() {
public void process(Exchange exchange) throws Exception {
logger.info("qqq2");
InputStream is = exchange.getIn().getBody(InputStream.class);
exchange.getContext().stop();
}
});
我在利用spring boot。
我有与骆驼相关的依赖关系,比如:
<artifactId>camel-ftp</artifactId>
通常情况下,在同一个项目中,我可以连接到STFP,并可以下载文件:
JSch jsch = new JSch();
Session session = null;
ChannelSftp sftpChannel = null;
用于相同的属性。 所以,密码,用户名,路径是正确的。
一开始,日志是这样说的:
Route: route3 shutdown complete, was consuming from: sftp://192.168.149.11:22/home/us/POLICE_BELGE_MUTABAKAT/GUNLUK/?fileName=f1.txt&password=xxxxxx&scheduler=quartz2&scheduler.cron=0+0%2F1+*+*+*+%3F+*+%3F&username=username
2020-07-04 16:04:33.440 INFO 24340 --- [detector-thread] o.a.camel.impl.DefaultShutdownStrategy :
我也试着改成
username@host
所以:
from("sftp://username@192.168.149.11:22/home/us/POLICE_BELGE_MUTABAKAT/GUNLUK/"
但还是一样。
通常情况下,从本地运行:
from("file:C:\\dev\\GitRepository\\war3" +
"?fileName=f2.txt"
所以,这是关于sftp的
我认为你的问题是你的spring boot应用程序正在立即关闭。
确保Camel Context在独立的spring boot中运行
将以下内容添加到src/main/resources
中的application.properties
中
camel.springboot.main-run-controller=true