title: Spring Integration flow picked up file keeps appearing in the local folder
body: <p>I have a document server applications. Separate flows are there for files picked up from the ftp folder and put in the local directory. The second flow is for files getting picked up and put in the FTP location. I have added a AcceptOnceFileListFilter for both as well as a custom pattern matcher which is same in both cases (something~something). The local directory as well as the ftp folder are different for this.</p>
  
  <p>I need to let the source files exist even after being picked up, hence I have removed the deletesourcefiles attribute. </p>
  
  <p>With this I am facing a problem of files repeatedly coming to the filter and getting processed. How can this happen with the AcceptOnceFileListFilter in place? I would anyway need to avoid the same files repeatedly getting processed.</p>
  
  <p>This is my entire configuration.</p>
  
  <pre><code>          &lt;bean id="fileNameGenerator" class="com.polling.util.FileNameGenerator"/&gt;   
      &lt;int-file:inbound-channel-adapter id="filesIn" directory="file:${paths.root}" channel="abc" filter="compositeFilter" prevent-duplicates="true" &gt;
          &lt;int:poller id="poller" fixed-rate="500" error-channel="errorChannel" /&gt;
  
      &lt;/int-file:inbound-channel-adapter&gt;
      &lt;int:service-activator input-channel="errorChannel" ref="errorLogger" method="logError"/&gt;
      &lt;bean id="errorLogger" class="com.polling.util.ErrorLogger" /&gt;
      &lt;int:channel id="abc"/&gt;
      &lt;bean id="compositeFilter" class="org.springframework.integration.file.filters.CompositeFileListFilter"&gt;
          &lt;constructor-arg&gt;
              &lt;list&gt;
                  &lt;!-- Ensures that the file is whole before processing it --&gt;
                  &lt;bean class="org.springframework.integration.file.filters.AcceptOnceFileListFilter" /&gt;
                  &lt;bean class="com.polling.util.CustomFileFilter"/&gt;
                  &lt;!-- Ensures files are picked up only once from the directory --&gt;
  
              &lt;/list&gt;
          &lt;/constructor-arg&gt;
      &lt;/bean&gt; 
  
      &lt;int-file:outbound-channel-adapter channel="abc" id="filesOut"
          directory-expression="@outPathBean.getPath()"
          delete-source-files="true" filename-generator="fileNameGenerator" temporary-file-suffix=".writinginprog"&gt;
          &lt;int-file:request-handler-advice-chain&gt;
           &lt;bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice"&gt;
              &lt;property name="onSuccessExpression" value="payload.delete()" /&gt;
            &lt;/bean&gt;
      &lt;/int-file:request-handler-advice-chain&gt;
          &lt;/int-file:outbound-channel-adapter&gt;
     &lt;bean id="ftpClientFactory"
      class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory"&gt;
      &lt;property name="host" value="${ftp.ip}"/&gt;
      &lt;property name="port" value="${ftp.port}"/&gt;
      &lt;property name="username" value="${ftp.username}"/&gt;
      &lt;property name="password" value="${ftp.password}"/&gt;
      &lt;property name="clientMode" value="0"/&gt;
      &lt;property name="fileType" value="2"/&gt;
      &lt;property name="bufferSize" value="100000"/&gt;
  &lt;/bean&gt;
  &lt;int:channel id="ftpChannel1"/&gt; 
   &lt;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" 
      &gt;
      &lt;int:poller fixed-rate="1000" error-channel="errorChannel"/&gt;
  &lt;/int-ftp:inbound-channel-adapter&gt;
    &lt;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"&gt;
      &lt;int-ftp:request-handler-advice-chain&gt;
           &lt;bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice"&gt;
              &lt;property name="onSuccessExpression" value="payload.delete()" /&gt;
            &lt;/bean&gt;
      &lt;/int-ftp:request-handler-advice-chain&gt;
  &lt;/int-ftp:outbound-channel-adapter&gt;
  
  
  
     &lt;int:channel id="ftpChannel"/&gt;
  &lt;!--filter="compositeFilterRemote"   filename-pattern="*~*"   filename-pattern="*~*"--&gt;
  &lt;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"&gt;
      &lt;int:poller fixed-rate="1000" error-channel="errorChannel"/&gt;
  &lt;/int-ftp:inbound-channel-adapter&gt;
  &lt;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"&gt;
      &lt;int-ftp:request-handler-advice-chain&gt;
           &lt;bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice"&gt;
              &lt;property name="onSuccessExpression" value="payload.delete()" /&gt;
            &lt;/bean&gt;
      &lt;/int-ftp:request-handler-advice-chain&gt;
    &lt;/int-ftp:outbound-channel-adapter&gt;
  &lt;bean id="compositeFilterLocal" class="org.springframework.integration.file.filters.CompositeFileListFilter"&gt;
          &lt;constructor-arg&gt;
              &lt;list&gt;
                  &lt;!-- Ensures that the file is whole before processing it --&gt;
                  &lt;bean class="org.springframework.integration.file.filters.AcceptAllFileListFilter" /&gt;
                  &lt;bean class="com.polling.util.CustomFileFilterLocal"/&gt;
                  &lt;!-- Ensures files are picked up only once from the directory --&gt;
  
              &lt;/list&gt;
          &lt;/constructor-arg&gt;
      &lt;/bean&gt;
      &lt;bean id="compositeFilterRemote" class="org.springframework.integration.file.filters.CompositeFileListFilter"&gt;
          &lt;constructor-arg&gt;
              &lt;list&gt;
                  &lt;!-- Ensures that the file is whole before processing it --&gt;
                  &lt;bean class="org.springframework.integration.file.filters.AcceptAllFileListFilter" /&gt;
                  &lt;bean class="com.polling.util.CustomFileFilterRemote"/&gt;
                  &lt;!-- Ensures files are picked up only once from the directory --&gt;
  
              &lt;/list&gt;
          &lt;/constructor-arg&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <ol>
  <li>ftpChannel picks file from ftp folder and puts in local directory
  abc picks the file from there and puts the renamed file to a dynamically generated folder.</li>
  <li>ftpchannel1 picks file on another local directory and puts it on the remote folder.</li>
  </ol>
  
  <p>EDIT:</p>
  
  <p>Changed the configuration from fixed-rate to fixed-delay. I don't remember why I had changed it to fixed-rate last month! Anyway, the large file problem is resolved as of now. The acceptoncefilter still does not do its job though. The does not delete the file from the local directory after the file inbound adapter picks it up. </p>
  
  <p>There is another issue. There are two ftp channels with different remote folders and different local folders. I want each to be unidirectional. Means one should pick up files from the remote dir and put it on the local one and the other should be vice-versa. Because of the above problem the file is still in the local dir and gets picked up by the other flow and put back on the remote directory! Cannot null one of the dir either. Please guide me in this as it is essential to not delete the files on the remote dir.</p>