我是春季整合的新手,所以请原谅我,如果我问一些普通的东西。我有一个简单的用例。我已经配置了ftp入站通道适配器,如下所示。使用它我能够在本地目录中提取远程检查文件。 i.e.D:/出站。现在我想轮询本地目录,即D:/ Outbound来添加更多业务逻辑。即基于检查文件状态从远程下载原始文件并将相关检查文件移动到其他目录位置。我应该怎么做?任何示例快速代码或参考指南/链接将不胜感激。如何通过ftp入站通道适配器轮询本地ftp目录?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-ftp="http://www.springframework.org/schema/integration/ftp"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/integration/ftp http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd">
<context:property-placeholder location="/ftp/ftp.properties"/>
<context:component-scan base-package="com.sandbox.ftp"/>
<!-- FTP inbound channel adapter for reading the input check files -->
<int-ftp:inbound-channel-adapter id="ftpInbound"
channel="ftpInboudChannel"
session-factory="ftpClientFactory"
auto-create-local-directory="true"
local-directory="D:/outBound"
remote-directory="."
filename-regex=".*\.chk$">
<int:poller fixed-rate="5000" />
</int-ftp:inbound-channel-adapter>
<int:channel id="ftpInboudChannel"/>
<!--Service Activator which will intiates the download of original source file -->
<int:service-activator input-channel="ftpInboudChannel" ref="myPojo" method="processFile" />
<bean id="myPojo" class="com.sandbox.ftp.CheckFileProcessor" />
<!-- FTP inbound channel adapter for downloading the original remote files -->
<int-ftp:inbound-channel-adapter id="ftpInboundDownload"
channel="ftpInboudDownloadChannel"
session-factory="ftpClientFactory"
auto-create-local-directory="true"
local-directory="D:/outBound/original"
remote-directory="."
filename-regex=".*\.txt$">
<int:poller fixed-rate="5000"/>
</int-ftp:inbound-channel-adapter>
<int:channel id="ftpInboudDownloadChannel"/>
</beans>
现在基于Gary的评论,我使用了服务激活器,并能够下载原始源文件.i.e。 *。文本。现在,我想在下载原始源文件后将关联的检查文件移动到同一文件夹。即* .chk到D:/ outBound/original。有什么想法吗 ?
你能澄清你所说的“进一步的业务逻辑”是什么意思? SO不建议参考指南,但这不是你的问题。 – Teepeemm
@Teepeemm感谢您的及时回复。在这里,通过“更进一步的商业逻辑”,对于这种用例,我的意思是“根据检查文件状态从远程下载原始文件并将相关检查文件移动到其他目录位置”。 – road2victory