【发布时间】:2015-06-15 15:28:15
【问题描述】:
我每天都在尝试从 FTP 服务器读取带日期戳的文件,例如 16:15。为了了解如何执行此操作,我尝试连接到 FTP 服务器,每分钟一次,每次都增加文件号。
目前我写的代码是:
private String readFtp = "quartz2://exchange/readFtp?cron=";
private String cronExpression = "1 * * * * ?";
private int i=0;
@Override
public void configure() throws Exception {
from(readFtp+cronExpression).process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
System.out.println("Triggered the process");
from(getFtpServerUrl())
.bean(RateServiceImpl.class, "update")
.log("Downloaded file ${file:name} complete.");
}
});
}
private String getFtpServerUrl() {
i++;
System.out.println("Here with i=" + i);
return String.format("ftp://%s:21/%s?username=%s&password=%s&fileName=%s", ftpServer, ftpPath, ftpUsername, ftpPassword, "rate"+i+".xml");
}
当我运行它时,它每分钟打印一次"Triggered the process"。它也调用getFtpServerUrl。
它没有调用RateServiceImpl.update。它没有记录"Downloaded file ${file:name} complete."。
- 我是不是走错了路?
- 有没有更简单的方法来构造每分钟的文件名?
- 为什么不调用
RateServiceImpl.update?
【问题讨论】:
标签: java apache-camel camel-ftp