Spring integration Spring集成流拾取的文件一直显示在本地文件夹中
我有一个文档服务器应用程序。对于从ftp文件夹中拾取并放入本地目录的文件,有单独的流。第二个流用于拾取文件并将其放入FTP位置。我为这两种情况都添加了一个AcceptOnceFileListFilter以及一个在这两种情况下都相同的自定义模式匹配器(something~something)。本地目录和ftp文件夹对此是不同的 我需要让源文件存在,即使在被拾取之后,因此我删除了deletesourcefiles属性 有了这个,我就面临着一个问题:文件会反复出现在过滤器中并得到处理。在AcceptOnceFileListFilter就绪的情况下,如何实现这一点?无论如何,我都需要避免重复处理相同的文件 这是我的全部配置Spring integration Spring集成流拾取的文件一直显示在本地文件夹中,spring-integration,Spring Integration,我有一个文档服务器应用程序。对于从ftp文件夹中拾取并放入本地目录的文件,有单独的流。第二个流用于拾取文件并将其放入FTP位置。我为这两种情况都添加了一个AcceptOnceFileListFilter以及一个在这两种情况下都相同的自定义模式匹配器(something~something)。本地目录和ftp文件夹对此是不同的 我需要让源文件存在,即使在被拾取之后,因此我删除了deletesourcefiles属性 有了这个,我就面临着一个问题:文件会反复出现在过滤器中并得到处理。在AcceptO
<bean id="fileNameGenerator" class="com.polling.util.FileNameGenerator"/>
<int-file:inbound-channel-adapter id="filesIn" directory="file:${paths.root}" channel="abc" filter="compositeFilter" prevent-duplicates="true" >
<int:poller id="poller" fixed-rate="500" error-channel="errorChannel" />
</int-file:inbound-channel-adapter>
<int:service-activator input-channel="errorChannel" ref="errorLogger" method="logError"/>
<bean id="errorLogger" class="com.polling.util.ErrorLogger" />
<int:channel id="abc"/>
<bean id="compositeFilter" class="org.springframework.integration.file.filters.CompositeFileListFilter">
<constructor-arg>
<list>
<!-- Ensures that the file is whole before processing it -->
<bean class="org.springframework.integration.file.filters.AcceptOnceFileListFilter" />
<bean class="com.polling.util.CustomFileFilter"/>
<!-- Ensures files are picked up only once from the directory -->
</list>
</constructor-arg>
</bean>
<int-file:outbound-channel-adapter channel="abc" id="filesOut"
directory-expression="@outPathBean.getPath()"
delete-source-files="true" filename-generator="fileNameGenerator" temporary-file-suffix=".writinginprog">
<int-file:request-handler-advice-chain>
<bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
<property name="onSuccessExpression" value="payload.delete()" />
</bean>
</int-file:request-handler-advice-chain>
</int-file:outbound-channel-adapter>
<bean id="ftpClientFactory"
class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
<property name="host" value="${ftp.ip}"/>
<property name="port" value="${ftp.port}"/>
<property name="username" value="${ftp.username}"/>
<property name="password" value="${ftp.password}"/>
<property name="clientMode" value="0"/>
<property name="fileType" value="2"/>
<property name="bufferSize" value="100000"/>
</bean>
<int:channel id="ftpChannel1"/>
<int-ftp:inbound-channel-adapter id="ftpInbound1"
channel="ftpChannel1"
session-factory="ftpClientFactory"
charset="UTF-8"
local-directory="file:${paths.downloadroot}"
delete-remote-files="true"
temporary-file-suffix=".write"
remote-directory="."
preserve-timestamp="true"
auto-startup="true"
local-filter="compositeFilterLocal"
>
<int:poller fixed-rate="1000" error-channel="errorChannel"/>
</int-ftp:inbound-channel-adapter>
<int-ftp:outbound-channel-adapter id="ftpOutbound1"
channel="ftpChannel1"
session-factory="ftpClientFactory"
charset="UTF-8"
remote-file-separator="/"
auto-create-directory="true"
remote-directory="${file.ftpdownloadfolder}"
use-temporary-file-name="true"
temporary-file-suffix=".write">
<int-ftp:request-handler-advice-chain>
<bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
<property name="onSuccessExpression" value="payload.delete()" />
</bean>
</int-ftp:request-handler-advice-chain>
</int-ftp:outbound-channel-adapter>
<int:channel id="ftpChannel"/>
<!--filter="compositeFilterRemote" filename-pattern="*~*" filename-pattern="*~*"-->
<int-ftp:inbound-channel-adapter id="ftpInbound"
channel="ftpChannel"
session-factory="ftpClientFactory"
charset="UTF-8"
local-directory="file:${paths.root}"
filter="compositeFilterRemote"
temporary-file-suffix=".writing"
remote-directory="${file.ftpfolder}"
delete-remote-files="true"
preserve-timestamp="true"
auto-startup="true">
<int:poller fixed-rate="1000" error-channel="errorChannel"/>
</int-ftp:inbound-channel-adapter>
<int-ftp:outbound-channel-adapter id="ftpOutbound"
channel="ftpChannel"
session-factory="ftpClientFactory"
charset="UTF-8"
remote-file-separator="/"
auto-create-directory="true"
remote-directory="${file.ftpfolder}"
use-temporary-file-name="true"
temporary-file-suffix=".writing">
<int-ftp:request-handler-advice-chain>
<bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
<property name="onSuccessExpression" value="payload.delete()" />
</bean>
</int-ftp:request-handler-advice-chain>
</int-ftp:outbound-channel-adapter>
<bean id="compositeFilterLocal" class="org.springframework.integration.file.filters.CompositeFileListFilter">
<constructor-arg>
<list>
<!-- Ensures that the file is whole before processing it -->
<bean class="org.springframework.integration.file.filters.AcceptAllFileListFilter" />
<bean class="com.polling.util.CustomFileFilterLocal"/>
<!-- Ensures files are picked up only once from the directory -->
</list>
</constructor-arg>
</bean>
<bean id="compositeFilterRemote" class="org.springframework.integration.file.filters.CompositeFileListFilter">
<constructor-arg>
<list>
<!-- Ensures that the file is whole before processing it -->
<bean class="org.springframework.integration.file.filters.AcceptAllFileListFilter" />
<bean class="com.polling.util.CustomFileFilterRemote"/>
<!-- Ensures files are picked up only once from the directory -->
</list>
</constructor-arg>
</bean>
还有一个问题。有两个具有不同远程文件夹和不同本地文件夹的ftp通道。我希望每个都是单向的。这意味着一个应该从远程目录中提取文件并将其放在本地目录中,而另一个则相反。由于上述问题,文件仍在本地目录中,并被另一个流拾取并放回远程目录!其中一个目录也不能为空。请在这方面指导我,因为不删除远程目录上的文件是至关重要的。AbstractPersistentAcceptonFileListFilter实现对您没有帮助吗?实现?我已经用xml对其进行了配置,如上所示。我第一次注意到这个问题时,虽然“删除源文件”属性为true,但如果文件大小大于30 mb,则文件入站适配器会成功拾取本地文件夹文件,然后始终保持拾取!!不,我的意思是
PersistentAcceptOnceFileListFilter
而不是内存中的AcceptOnceFileListFilter
请解释实现标签AbstractPersistentAcceptOnceFileListFilter
是抽象的。因此,要使用这些内容,您应该为您的案例选择特定的实现:filesystemtempersistentaptoncefilelistfilter
,ftppersistentacceptonfilelistfilter
等等。。