Reputation: 691
When I am trying to process a file in Camel and it fails I try to move the file to an error directory but get the following error message:
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot delete file:....
I don't know if Windows is locking the file, but I have closed any streams that may cause this to occur on my side. If this is Windows what could I do to release this lock?
The route is a simple from()... process().. to()
and there are some headers set after the process()
It is the to()
where this fails and the file does not move into the error directory as expected.
Thanks.
Upvotes: 3
Views: 3430
Reputation: 691
It seems there was a rogue stream that needed changing. I found this out using Process Explorer as it identified the same file twice. One lock was removed and another was not and from this I found an open stream that wasn't handled in the catch
block.
Upvotes: 2
Reputation: 23562
Maybe it has something to do with this:
Cannot move/delete file after processing on Windows
There is a potential issue on Windows platform with Camel 1.5.x. That it cannot move or delete the file after processing. You should get an exception thrown.
The workaround is to convert the body to a String after consuming using convertBodyTo: eg from("file://inbox").convertBodyTo(String.class).to("file://outbox");.
There should be a fix in Camel 1.6.0 to remedy this, but we would like to get feedback on this issue. So if you are on Windows please give it a go.
Upvotes: 2