Spring 如何使用int ftp:outbound gateway从ftp服务器接收目录或文件列表?
我定义了ftp适配器来连接到ftp服务器,但我看到了ftp服务器日志,并没有看到发送到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="
<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>