I need to download files through ftp every 5 minutes to local directory, process each of them and then remove from local directory. I have the following configuration for spring ftp inbound adapter
<int-ftp:inbound-channel-adapter
id="ftpPortAdapter"
channel="receiveChannel"
session-factory="ftpSessionFactory"
local-directory="/test"
local-filename-generator-expression="#this"
remote-directory="/prod"
auto-create-local-directory="true"
delete-remote-files="false"
filter="compositeFilter">
<int:poller fixed-delay="300000" max-messages-per-poll="-1"/>
</int-ftp:inbound-channel-adapter>
<bean id="compositeFilter" class="org.springframework.integration.file.filters.CompositeFileListFilter">
<constructor-arg>
<list>
<bean class="org.springframework.integration.file.filters.AcceptOnceFileListFilter"/>
<bean id="customFilter"
class="ru.lanit.parkomats.integration.impl.dozor.MyInboundChannelFilter">
<property name="initDate" value="2016-10-12 00:00:00"/>
</bean>
</list>
</constructor-arg>
</bean>
<int:channel id="receiveChannel">
</int:channel>
<int:service-activator input-channel="receiveChannel" ref="ftpFileService" method="processNewFiles">
<int:request-handler-advice-chain>
<bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
<property name="onSuccessExpression" value="payload.delete()"/>
<property name="onFailureExpression" value="payload.delete()"/>
</bean>
</int:request-handler-advice-chain>
</int:service-activator>
CustomFilter provides getting only files that were created on the remote directory for the last five minutes only. It looks like it first downloads files, parses them, removes and then downloads those same files again immediately after service activator finishes its jobs. How to you stop file pulling after service finishes parsing them. Or any other ideas?