I use Spring Integration to process CSV files manually added to a folder.
The beginning of my integration is :
<bean id="recursiveScanner" class="org.springframework.integration.file.RecursiveLeafOnlyDirectoryScanner" />
<int-file:inbound-channel-adapter channel="filesIn" directory="file:${integration.directory}" scanner="recursiveScanner">
<int:poller id="poller" fixed-delay="${integration.delay}" />
</int-file:inbound-channel-adapter>
Followed by custom service activators.
When I move a small file (few megs) in the scanned directory it works perfectly, but when it's a big file (93 Mio) I get an exception :
org.springframework.batch.item.ItemStreamException: Failed to initialize the reader
..........
Caused by: java.io.FileNotFoundException: D:\nreco-import-batch-2014\.\home\entries.csv (Le processus ne peut pas accéder au fichier car ce fichier est utilisé par un autre processus)
It says the file can't be read because already openned by another process.
My guess is that the Spring channel is triggered at the begining of the file transfer, when the file is still being copied by the operating system, thus is not yet readable.
So my question is: is there a way to configure the file inbound channel to be triggered only when the file copy is complete ?
For now I test in local, with very good transfer rates between by two HDD, but the app will be deployed on a server where the scanned directory will be accessed by FTP, I am sure it will fail for much smaller files then...
Thanks
edit: forgot to explain one part
one of my service activators (the final one) is a Spring Batch job which parses the newly added file, process the data and insert them in a MongoDB database
it's the Batch step actually reading the file which throws the Exception
org.springframework.batch.item.ItemStreamException: Failed to initialize the reader
: Actually, it's not an issue of Spring Integration File Polling Adapter. It's an issue from Spring Batch. Does it say anything for you? – Artem Bilan