Reputation: 463
I run an automatic route when files are dropped in a folder
<route id ="automatic-route">
<from uri="file:C:/pathToFolder?noop=true"/>
<to uri="bean:automaticBean"/>
<to uri="activemq:STARTFLOW.Q"/>
</route>
I move the file in a subfolder called "done" with java methods in my Bean AutomaticBean.java.
Then I start another route to process the file.
<route id ="process-route">
<from uri="direct:process"/>
<to uri="bean:processBean"/>
</route>
When I move multiple files in the folder they are correctly moved to the subfolder (through my Bean. I use java method to move them). But then the second bean (file processing and SQL queries) has timeoutException because the files are moved and processed at the same time.
For example when I move 5 files 3 of them are correctly processed but then the last ones have a timeoutException. Is it possible to run the second route for each files one by one (schedule them or something like that)? And only start the second route for a file when the previous file is correctly processed?
I tried with noop=false;move=done and I have infinite loop problems and I cannot process the files because they moved. That's why I use noop=true. Furthermore my problem is about the second route (the files are all correctly moved).
Thanks.
Upvotes: 0
Views: 207
Reputation: 463
Actually adding a delay an set maxMessagePerPoll to 1 did the trick
<route id ="process-route">
<from uri="file:C:/pathToFolder/noop=true&delay=10000&maxMessagesPerPoll=1"/>
<to uri="bean:processBean"/>
</route>
Upvotes: 0
Reputation: 2677
One solution can be to poll the /done
folder for the new files (which have been processed and moved by your automaticBean
). In this case you have to use readLock
or doneFileName
to check if the file isn't locked by another process.
<route id ="process-route">
<from uri="file:C:/pathToFolder/done?readLock=changed"/>
<to uri="bean:processBean"/>
</route>
Upvotes: 1