【发布时间】:2023-03-21 18:34:02
【问题描述】:
首先感谢关注
我定义出站网关 ftp 适配器在目标服务器上运行 ftp 命令,我的目标是定期在服务器上运行 ls,mv,get,... 命令并在批处理库作业上运行任务,我的代码是:
<bean id="ftpClientFactory1" 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:gateway id="gw" service-interface="ir.ali.util.ToFtpFlowGateway"
default-request-channel="inbound1"/>
<int:channel id="inbound1"/>
<int-ftp:outbound-gateway id="gateway1"
session-factory="ftpClientFactory1"
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="-dirs -R"
expression="payload"
mput-regex=".*"
>
</int-ftp:outbound-gateway>
<int:channel id="outbound">
<int:interceptors>
<int:wire-tap channel="logger"/>
</int:interceptors>
</int:channel>
<int:channel id="outboundJobRequestChannel"/>
<int:logging-channel-adapter id="logger" log-full-message="true" />
<int:transformer input-channel="outbound" output-channel="outboundJobRequestChannel">
<bean class="ir.ali.configuration.FileMessageToJobRequest"/>
</int:transformer>
<int:splitter id="splitter" input-channel="outbound" output-channel="ftpChannel"/>
<int:channel id="ftpChannel">
<int:queue/>
</int:channel>
在应用程序类中向inbound1频道发送消息并启动int-ftp:outbound-gateway,代码为:
final ToFtpFlowGateway toFtpFlow = ctx.getBean(ToFtpFlowGateway.class);
try {
List<Boolean> rmResults = toFtpFlow.lsGetAndRmFiles("/");
} catch (Exception e) {
e.printStackTrace();
}
它工作正常,问题是我需要在服务器上运行定期 ls 和 mv ,...递归命令,如何定期运行toFtpFlow.lsGetAndRmFiles("/"); 来启动int-ftp:outbound-gateway?
【问题讨论】:
标签: spring ftp spring-integration