【问题标题】:how to get sub directories in int-ftp:outbound-gateway with expression?如何使用表达式获取 int-ftp:outbound-gateway 中的子目录?
【发布时间】:2015-04-20 12:58:51
【问题描述】:

首先感谢关注 我有一个 spring 集成项目,它监听 ftp 服务器接收不同目录中的文件并处理它,ftp 目录结构是:
ftp-root
------------一个\
--在\
---------------------------a.txt
------退出\
------------b\
--在\
---------------------------------------b.txt
------退出\

我使用int-ftp:outbound-gateway适配器运行ls递归命令,如何在int-ftp:outbound-gateway中编写expression attr,得到a.txtb.txt in 目录,我的适配器代码是:

 <int-ftp:outbound-gateway id="gateway1"
                              session-factory="ftpClientFactory"
                              request-channel="inbound1"
                              reply-channel="outbound"
                              reply-timeout="777"
                              auto-create-local-directory="false"
                              auto-startup="true"
                              command="ls"
                              command-options="-1 -R"
                              expression="'*/in/'"
                              mput-regex=".*">

    </int-ftp:outbound-gateway>

但没有正确工作,怎么写?

【问题讨论】:

    标签: spring ftp spring-integration


    【解决方案1】:

    看起来MGET 操作适合你:

    <int-ftp:outbound-gateway id="gatewayLS"
        session-factory="ftpSessionFactory"
        request-channel="inbound"
        command="mget"
        command-options=""
        expression="payload"
        local-directory="/tmp/out"
        reply-channel="resultChannel"/>
    

    FTP Outbound Gateway MGET.

    【讨论】:

    • 是的没错,如何写expression attr 只获取子目录,将expression 设置为/*/in/ 但不能正常工作
    • 它不起作用。请阅读我指出的文档。你真的需要filter 来跳过文件,因此不需要的目录
    • ,适配器已更改但抛出以下异常org.springframework.messaging.MessagingException: ; nested exception is org.springframework.messaging.MessagingException: Failed to execute on session; nested exception is java.lang.IllegalArgumentException: path must not be null感谢帮助我
    • 您没有尝试使用* 作为请求消息中的路径吗?
    • 它工作正常@Artem &lt;int-ftp:outbound-gateway id="gateway1" session-factory="ftpClientFactory" request-channel="inbound1" reply-channel="outbound" reply-timeout="777" command="mget" command-options="-R" expression="payload" local-directory="." &gt; &lt;/int-ftp:outbound-gateway&gt;
    猜你喜欢
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 2022-10-14
    • 1970-01-01
    • 2016-06-27
    相关资源
    最近更新 更多