【问题标题】:Polling directory with multiple sub-directories具有多个子目录的轮询目录
【发布时间】: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


    【解决方案1】:

    您需要更详细地解释您的问题 - “没有工作”是严重不足的,并且您不会在此问题上获得太多帮助。您需要展示您尝试过的内容和观察到的内容。

    recursive mget 和 recursive mput 都有测试用例。

    测试的目录结构显示在该文件顶部的注释中。

    我建议您将这些与您尝试过的进行比较,如果您有特定的问题/观察,请回到这里。解决这些问题最好的办法是打开 DEBUG 日志记录;包括 jsch。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-24
      • 2022-07-02
      • 1970-01-01
      • 1970-01-01
      • 2021-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多