【问题标题】:Why int-ftp:outbound-gateway payload is not List<java.io.File>?为什么 int-ftp:outbound-gateway 有效负载不是 List<java.io.File>?
【发布时间】:2016-06-27 06:23:53
【问题描述】:

根据http://docs.spring.io/spring-integration/reference/html/ftp.html#ftp-outbound-gateway,mget payload 是一个文件列表

mget 基于模式检索多个远程文件,并支持以下选项:

...

mget 操作产生的消息负载是一个 ListFile> 对象 - 一个文件对象列表,每个对象代表一个检索到的文件。

我有以下配置

<int-ftp:outbound-gateway 
        session-factory="ftpSesionFactory"
        request-channel="request-channel"
        reply-channel="reply-channel" 
        auto-create-directory="true"
        local-directory="${local-directory}"        
        command="mget" 
        command-options="-stream" 
        expression="payload">
        <int-ftp:request-handler-advice-chain>
            <int:retry-advice />
        </int-ftp:request-handler-advice-chain>
    </int-ftp:outbound-gateway>
<int-file:splitter input-channel="reply-channel" output-channel="logger"/>  

但有效载荷是一个 ListFTPFile> 并且拆分器不起作用。这是一个错误吗?如何在有效负载中获取下载的 Listjava.io.File>(如文档所述)?。

解决方法是使用另一个组件从本地目录读取文件,如how to get file with int-ftp:outbound-gateway and remove from server if exists? 所述。

我正在使用 spring-integration 4.2.5 和 commons-net-2.0。

【问题讨论】:

    标签: spring-integration apache-commons-net


    【解决方案1】:

    是什么让你相信它是List&lt;FTPFile

    This test 表明它是List&lt;java.io.File&gt;

    ls 命令返回StringFTPFile 的列表,具体取决于-1 选项。

    最后,mget 不支持-stream,只有get

    此外,您不希望那里有一个文件拆分器 - 读取每个文件 - 您需要一个常规的 &lt;int:splitter/&gt;List&lt;File&gt; 拆分为单独的文件;然后文件拆分器将读取文件行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-21
      • 2011-07-01
      • 1970-01-01
      • 2023-04-08
      • 1970-01-01
      • 2018-12-15
      • 1970-01-01
      • 2010-11-05
      相关资源
      最近更新 更多