Spring ftp integration. Delete files after processing
<p>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</p>

<pre><code>&lt;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"&gt;
    &lt;int:poller fixed-delay="300000" max-messages-per-poll="-1"/&gt;
&lt;/int-ftp:inbound-channel-adapter&gt;

&lt;bean id="compositeFilter" class="org.springframework.integration.file.filters.CompositeFileListFilter"&gt;
    &lt;constructor-arg&gt;
        &lt;list&gt;
            &lt;bean class="org.springframework.integration.file.filters.AcceptOnceFileListFilter"/&gt;
            &lt;bean id="customFilter"
                class="ru.lanit.parkomats.integration.impl.dozor.MyInboundChannelFilter"&gt;
                &lt;property name="initDate" value="2016-10-12 00:00:00"/&gt;
            &lt;/bean&gt;
        &lt;/list&gt;
    &lt;/constructor-arg&gt;
&lt;/bean&gt;

&lt;int:channel id="receiveChannel"&gt;
&lt;/int:channel&gt;

&lt;int:service-activator input-channel="receiveChannel" ref="ftpFileService" method="processNewFiles"&gt;
    &lt;int:request-handler-advice-chain&gt;
        &lt;bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice"&gt;
            &lt;property name="onSuccessExpression" value="payload.delete()"/&gt;
            &lt;property name="onFailureExpression" value="payload.delete()"/&gt;
        &lt;/bean&gt;
    &lt;/int:request-handler-advice-chain&gt;
&lt;/int:service-activator&gt;
</code></pre>

<p>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?</p>