【发布时间】:2021-10-06 06:12:14
【问题描述】:
我在数据库中存储的文件很少,这些文件是从 FTP 服务器获取并处理的。
我正在尝试将这些文件移动到 FTP 服务器上的存档目录,为此我正在使用 producerTemplate。
这是我到目前为止所做的。
try {
DefaultCamelContext camelContext = new DefaultCamelContext();
ProducerTemplate template = camelContext.createProducerTemplate();
template.request("ftp://xxxxx/include=fileFromDb.xml&move=archive/fileFromDb.xml", outExchange -> {
String body = outExchange.getIn().getBody(String.class);
});
} catch (Exception ex) {
// update the status in database to indicate archive failed
}
但这失败并出现以下错误,无法解决。
WARN o.a.c.c.f.remote.RemoteFileProducer - Writing file failed with: Cannot write null body to file: archive/ID-192-168-1-113-tpgi-com-au-1627667653835-1-2
我已经尝试从其他答案中实施解决方案,但它们都没有奏效。
如果我像下面这样编写自定义路由,它可以正常工作,但因为我需要执行我更喜欢使用生产者模板的移动后操作。
from("ftp://xxxxx/include=fileFromDb.xml&move=archive/fileFromDb.xml")
.log("file moved successfully").
【问题讨论】:
标签: spring apache-camel camel-ftp