Reputation: 1903
Good day,
I am using spring integration 2.2 to build the listener to a folder. May I know how can I check will my listener pick up file when file transferring half way? Or it will wait until the complete file has been transferred?
Let say there is a txt file with 10MB, but due to internet slowness, the file taking 10 seconds to transfer to the folder. Let say at the 5th second, the file only done transfer 5MB, still 5MB to go, possible the listener go to pick up the file and process?
Here is part of my listener code in xml:
<int-file:inbound-channel-adapter id="hostFilesIn" directory="${hostfile.dir.in}"
prevent-duplicates="true" filename-regex="${hostfile.in.filename-regex}">
<int:poller id="poller" fixed-rate="${poller.fixrate:15000}" max-messages-per-poll="1" />
</int-file:inbound-channel-adapter>
Let me know if need more information.
Here is the problem that happen:
From the log, we can saw a file is being added to queue,
2019-02-01 11:13:33.011 [task-scheduler-9] DEBUG org.springframework.integration.file.FileReadingMessageSource - Added to queue: [/apps/NAS/ftp/in/incompleteL041.TXT]
After that hitting the following error:
2019-02-01 11:13:33.096 [task-scheduler-9] DEBUG c.c.c.c.g.a.auditservice.SimpleErrorIdResolver - ERROR MESSAGE7 :
java.io.FileNotFoundException: /apps/NAS/ftp/in/incompleteL041.TXT (A file or directory in the path name does not exist.)
Its because, when the file finish transfer, it will rename it to L041.TXT.
Kindly advise.
Upvotes: 0
Views: 1841
Reputation: 121550
Your understanding is fully correct. That's how file system behaves. If file is already there, even if it is still in writing mode, it is visible for all others including the mentioned file reading message source.
To prevent reading non-complete files you really need to implement a logic when non-finished file has a different name and filters on the file inbound channel adapter should be configured the way that they don't see such a file.
Something like this regexp ^(incomplete).*?\.TXT
should work for you current explanation.
Upvotes: 1