title: Apache Camel GenericFileOperationFailedException: 'Cannot rename file' locks exchange
body: <p>We have an integration system based on Camel v2.16.1 that runs on a Jboss v6 Linux platform.  There are multiple interfaces running simultaneously each with a different polling rate.</p>
  
  <p>We are intermittently experiencing 'Cannot rename file' issue with Camel failing to backup to the 'done' folder successfully processed and transmitted files from the FTP source.  Restarting the camel application fixes the issue.</p>
  
  <p>Basically, at regular intervals triggered by a quartz scheduler, the route: </p>
  
  <ol>
  <li>picks up files from a source via FTP,</li>
  <li>processes them, smooks + xsl transformations</li>
  <li>delivers the generated flat file to an endpoint via FTP.</li>
  </ol>
  
  <p>If multiple files are read from the source directory, then all the files are appended together in a temporary file before being processed.</p>
  
  <p>The Camel FTP configuration uses the following URL:</p>
  
  <blockquote>
    <p><a href="ftp://xxxx/export?antInclude=dsciord_" rel="nofollow">ftp://xxxx/export?antInclude=dsciord_</a>*.dat&amp;inProgressRepository=#warehouseIntegrationIdempotentRepository&amp;preMove=in_progress_bpo/$simple{date:now:yyyyMMddHHmm}/$simple{file:name}&amp;move=done&amp;consumer.bridgeErrorHandler=true</p>
  </blockquote>
  
  <ol>
  <li>read files <code>dsciord_*.dat</code> from <code>/export</code> directory</li>
  <li>use custom <code>inprogressRepository</code> to store the read filename into a local db (this was done to prevent contention issue with a second cluster node, however, currently only a single node is live.  This option is unnecessary and can be removed speeding up the process).</li>
  <li>move files to an <code>in_progress_bpo/201609061522</code> directory, where the subdirectory is created based on the date_timestamp.  </li>
  <li>move them to the <code>in_progress_bpo/201609061522/done</code> subdirectory once successfully processed.</li>
  </ol>
  
  <p>In vast majority of cases the route works with no issues, however, sometimes the file(s) cannot be moved to the done folder (see error below).  Even in this case, the route can sometimes continue successfully at the next polling cycle, however, in other cases the route enters a state when even if the quartz scheduler triggers the poll, the route fails to detect any files in the source /export directory even when there ARE files there.</p>
  
  <blockquote>
    <p>org.apache.camel.component.file.GenericFileOperationFailedException: Cannot rename file: RemoteFile[in_progress_bpo/201609060502/dsciord_3605752.dat] to: RemoteFile[in_progress_bpo/201609060502/done/dsciord_3605752.dat]</p>
  </blockquote>
  
  <p>Notes: We are using </p>
  
  <ol>
  <li>a single instance of a <code>ConsumerTemplate</code> to handle our interfaces.</li>
  <li>a custom <code>inprogressRepository</code> to store the file names read.</li>
  </ol>
  
  <p>Obviously, there must be a system locking the source files and this is causing the Camel route to stop processing further files.</p>
  
  <p>Any ideas/suggestions on debugging/resolving this issue would be greatly appreciated.  The issues that I read through the camel-users forum seem to deal with Windows-related deployments, sometimes Smooks failing to close the input stream.  I've check and we don't use the 
  <code>org.milyn.templating.xslt.XslTemplateProcessor#bypass</code> method where Smooks fails to close the underlying input stream.</p>