apache-camelsoaenterprise-integration

File component(Apache camel) delete=true parameter not working in windows


The Apache Camel File component not working properly in Windows7, where as its working in Linux without any Problem.

My Requirement:

After the file processing, the files must be deleted from the Directory. In Windows, because of .camelLock the files are not deleting properly.

After Multiple attempts, then only Apache camel can delete the file from the Directory. If the attemt failed to delete the file from the Directory then its throwing an exception.

If I have only a File in the Directory, it's working without any Problem, but if i have multiple Files then it's throwing an Exception.

Application Environment:

I deployed the Apache camel application in Tomcat Server.

Apache Camel version: 2.17.1

Apache Camel Route:

 <from uri="file:///var/opt/irs/message?delete=true" />
 <to uri="direct:file.storage.original" />

In Windows I am receiving following Error:

enter image description here

1|2017-11-14 17:56:34,828|11-01-41|default|WARN
|yes||o.a.c.c.f.GenericFileOnCompletion|file.analysis.input|Error during commit. Exchange[ID-51741-1510678404569-9-22]. Caused by: [org.apache.camel.component.file.GenericFileOperationFailedException - Cannot delete file: GenericFile[C:\var\opt\irs\message\661.zip]] org.apache.camel.component.file.GenericFileOperationFailedException: Cannot delete file: GenericFile[C:\var\opt\irs\message\661.zip] at org.apache.camel.component.file.strategy.GenericFileDeleteProcessStrategy.commit(GenericFileDeleteProcessStrategy.java:89) at org.apache.camel.component.file.GenericFileOnCompletion.processStrategyCommit(GenericFileOnCompletion.java:127)

Similar Problems: Camel 2.15 file locks , Camel 2.14.2 not deleting files on Windows ,deleting moving files


Solution

  • In this case, I forgot to close file input stream. so that's why I had a problem in Windows.

    I am using InputStream unnecessarily for the Filecomponent. I removed it, everything working file.

    InputStream input = CamelContextHelper.convertTo(context, InputStream.class, body);
    

    If anybody has same problem, just close the file InputStream properly or Cross-check your code and try to replace it with other proper alternative solution.

    Alternative Solution:

    In case,if you are unable to find open streams in your code, then apply below parameters to Apache camel route. The performance would be better.

    readLockCheckInterval=1&amp;readLockTimeout=3
    

    In my case Performance much better in windows.