【发布时间】:2018-02-22 12:07:21
【问题描述】:
我是 Spring Integration 的新手,我需要建立一个到只接受 GET 和 PUT 命令的服务器的 FTP 连接。
我配置了一个 FtpOutboundGateway 和 @MessagingGateway ,这实际上是有效的。
但是FtpOutboundGateway 的设置
@Bean
@ServiceActivator(inputChannel = "ftpFetchFile")
public MessageHandler getFile() {
FtpOutboundGateway gateway = new FtpOutboundGateway(this.ftpSessionFactory(), "get", "payload");
gateway.setLocalDirectoryExpression(EXPRESSION_PARSER.parseExpression("#remoteDirectory"));
gateway.setFileExistsMode(FileExistsMode.REPLACE);
return gateway;
}
还在GET 之前执行LS 命令。这实际上是一种很好的方法,可以证明文件存在,但是由于服务器正在动态创建文件,LS 永远不会返回任何现有文件,因此在来自org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.get(Message<?>, Session<F>, String, String, String, boolean) 的 MessagingException 中运行:
failure occurred in gateway sendAndReceive: Dispatcher failed to deliver Message; nested exception is org.springframework.messaging.MessagingException: someFile.txt is not a file
有没有办法用 Ftp GET 检索文件?
【问题讨论】: