1

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

Narayan Yerrabachu
  • 1,714
  • 1
  • 19
  • 31
  • 3
    There is some other process that has a lock on that file in windows so Camel (eg Java JVM) cannot delete the file. So take a look on your Windows box what may be holding a lock on the files. Or you do something in that direct route (which we cannot see) where you forget to close some file input or something so the file is locked. So double check your code. – Claus Ibsen Nov 15 '17 at 14:39
  • I am facing this problem only with file component. I tried with FTP in windows its working fine. – Narayan Yerrabachu Nov 15 '17 at 14:53
  • Are you unzipping the files? Opening the Zip in anyway will cause a lock on the zip file. – Namphibian Nov 15 '17 at 21:48

1 Answers1

1

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.

Narayan Yerrabachu
  • 1,714
  • 1
  • 19
  • 31