【发布时间】:2015-10-21 20:27:42
【问题描述】:
我正在尝试构建一个简单的实用程序,它将文件从多个目录从一个 sftp 服务器复制到另一台服务器。
我尝试使用 sftp 出站网关通过命令 "mget" 轮询单个高级目录,但它不起作用。所以我想写两个入站适配器(不是一个好的解决方案,但仍然希望这个做得不好!)。
<int-sftp:inbound-channel-adapter
id="pdbInbound"
session-factory="sftpSessionFactory"
auto-create-local-directory="true" delete-remote-files="true"
filename-pattern="*.*" remote-directory="${remote.pdb.directory}"
local-directory="${local.pdb.directory}">
<int:poller fixed-rate="5000"/>
</int-sftp:inbound-channel-adapter>
<int-sftp:inbound-channel-adapter
id="galaxyInbound"
session-factory="sftpSessionFactory"
auto-create-local-directory="true" delete-remote-files="true"
filename-pattern="*.*" remote-directory="${remote.galaxy.directory}"
local-directory="${local.galaxy.directory}" >
<int:poller fixed-rate="5000"/>
</int-sftp:inbound-channel-adapter>
以上代码运行良好,文件按预期复制到本地目录。
当我需要将这些文件传输到与源目录具有相同目录结构的远程目录时出现问题。我无法使用带有命令 =“mput”和命令选项 =“-R”的 sftp-outbound 网关来实现它。因此,我尝试编写两个出站适配器,如下所示。但是只有一个目录被写入远程。 知道这里出了什么问题吗?
<int:service-activator input-channel="pdbInbound" output-channel="pdbOutbound" expression="payload"/>
<int:service-activator input-channel="galaxyInbound" output-channel="galaxyOutbound" expression="payload"/>
<int-sftp:outbound-channel-adapter id="sftPdbOutboundAdapter" auto-create-directory="true"
session-factory="sftpSessionFactory"
auto-startup="true"
channel="pdbOutbound"
charset="UTF-8"
remote-file-separator="/"
remote-directory="${remote.out.pdb.directory}"
mode="REPLACE">
</int-sftp:outbound-channel-adapter>
<int-sftp:outbound-channel-adapter id="sftpGalaxyOutboundAdapter" auto-create-directory="true"
auto-startup="true"
session-factory="sftpSessionFactory"
channel="galaxyOutbound"
charset="UTF-8"
remote-file-separator="/"
remote-directory="${remote.out.galaxy.directory}"
mode="REPLACE">
</int-sftp:outbound-channel-adapter>
<int:poller default="true" fixed-delay="50"/>
注意:出于测试目的,我对入站和出站文件使用相同的 sftp 服务器(但目录不同)。
【问题讨论】:
标签: spring spring-integration sftp