Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 如何使用int ftp:outbound gateway从ftp服务器接收目录或文件列表?_Spring_Ftp_Spring Integration_Outbound - Fatal编程技术网

Spring 如何使用int ftp:outbound gateway从ftp服务器接收目录或文件列表?

Spring 如何使用int ftp:outbound gateway从ftp服务器接收目录或文件列表?,spring,ftp,spring-integration,outbound,Spring,Ftp,Spring Integration,Outbound,我定义了ftp适配器来连接到ftp服务器,但我看到了ftp服务器日志,并没有看到发送到ftp服务器的请求。我的适配器代码是: <bean id="ftpClientFactory" class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory"> <property name="host" value="127.0.0.1"/> <property name="

我定义了ftp适配器来连接到ftp服务器,但我看到了ftp服务器日志,并没有看到发送到ftp服务器的请求。我的适配器代码是:

<bean id="ftpClientFactory" class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
    <property name="host" value="127.0.0.1"/>
    <property name="port" value="21"/>
    <property name="username" value="banks_reader"/>
    <property name="password" value="123456"/>
    <property name="clientMode" value="2"/>
    <property name="fileType" value="2"/>

</bean>


<int:channel id="inbound1">
    <int:queue/>
</int:channel>
<int:channel id="outbound"/>
<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"
                          filename-pattern="*"
                          remote-file-separator="/"
                          command="ls"
                          command-options="-1 -f"
                          expression="payload"
                          order="1"
                          mput-regex=".*">
    <int:poller fixed-delay="1000"/>
</int-ftp:outbound-gateway>

当更改测试的usename和密码(假通过和usename)不会更改任何内容并引发异常时

您的配置看起来不错,但您错过了一个方法。
是一个事件驱动的请求/回复组件,在
inbound1
中没有
消息之前,它无法使用FTP执行任何操作。
即使是
也只有在轮询期间
没有收到任何消息的情况下才会启动其工作

由于您使用的是
expression=“payload”
,因此您的
requestMessage
必须包含来自FTP用户主页的
remote dir
payload

因此,只需将这样的消息发送到
inbound1
,并让我们知道它是怎样的

更新

要使用与
有效载荷相同的
dir
定期在
上执行
LS
命令,您必须如下配置:

<inbound-channel-adapter channel="inbound1" expresssion="'/'">
    <poller fixed-delay="10000"/>
</inbound-channel-adapter>


有了这个(以及您的
)案例,就不需要将
inbound1
频道作为

再次向
inbound1
发送消息。你没有分享你的流程的开始,这就是为什么我不能找出你有什么问题。您不能将假
配置为定期启动流。是的,没错,添加
int:gateway
并运行
toFtpFlow.lsGetAndRmFiles(“/”)在应用程序启动中,它工作正常,但只执行一次,如何定期执行语句以运行命令并获取对象列表?感谢@Artem帮助我并更新您的答案,根据文档,我需要运行ls、mv,。。。命令,如何运行
toFtpFlow.lsGetAndRmFiles(“/”)语句并获取对象列表?您可以将其作为一组连续的
组件来完成:第一个用于
LS
,然后是
,还有一个
用于
MV
谢谢@Artem,在第一步中,我需要定期调用LS commad并运行
流到LS MV,如何先定期运行
来运行ls命令?
<inbound-channel-adapter channel="inbound1" expresssion="'/'">
    <poller fixed-delay="10000"/>
</inbound-channel-adapter>