Reputation: 5455
The example route below picks up a file and performs a series of operations on them. Once completed, as noted in the camel:from
field, the route is instructed to move the file to a .processed
directory. Alternatively if failed, move it to the .error
folder.
The problem occurs when another process as a lock on the file (ie. excel) and camel is unable to move the file, therefore, it infinitely keeps retrying which is an undesired behaviour.
Adding a retrypolicy
or onException
will not solver this specific issue as I would not like to retry the entire route but rather retry the file move only
<camel:route id="aRoute">
<camel:from
uri="file://{{sourceFileLocation}}?include=fileToProcess.csv&moveFailed=.error/$simple{date:now:yyyy}/$simple{date:now:MM}/$simple{date:now:dd}/$simple{file:name}&move=.processed/$simple{date:now:yyyy}/$simple{date:now:MM}/$simple{date:now:dd}/$simple{file:name}"/>
<camel:setHeader headerName="CATEGORY">
<camel:constant>category a</camel:constant>
</camel:setHeader>
<camel:process ref="asOfDateService"/>
<camel:process ref="batchIdService"/>
<camel:process ref="aService"/>
<camel:to uri="log:aRoute"/>
<camel:process ref="factXLookup"/>
<camel:process ref="factXConversionInsert"/>
<camel:process ref="batchTableCleanupService"/>
<camel:process ref="batchUpdateService"/>
<camel:onException>
<camel:exception>java.lang.Exception</camel:exception>
<camel:process ref="batchFailedService"/>
</camel:onException>
</camel:route>
For clarification purposes you can ignore the onException
above as that is dealing with issues in the data integrity / quality of the process.
TLDR: How can I retry camel's file-move on completion without re-executing the entire route?
Upvotes: 2
Views: 1719
Reputation: 3349
This is something that the File component needs to handle, not your route.
You can configure how the File component should handle locked files using the readLock
option (along with other related options). The option has an extensive description on the File2 component documentation page
Upvotes: 2