I'm using Spring Integration to poll files from remote FTP server and process them.
Is there a way to configure FtpInboundFileSynchronizer (or other component) to fetch and process remote files in specific order. Say i have file1 and file2 in remote directory, is it possible to fetch and process file1 before file2.
Thanks in advance
There are (at least) 3 techniques to achieve this:
Add a custom
FileListFilter<FTPFile>
(that sorts theFTPFile
objects into the order you desire) to the synchronizer.Use two FTP outbound gateways, one the list (ls) the files, and one to get each file as needed.
Use the
FtpRemoteFileTemplate
from within your own code to list and fetch files.EDIT
Actually, for #1, you would also need a custom
FileListFilter<File>
in the local filter to sort theFile
objects. Since the local files are emitted as message payloads after the synchronization is complete.EDIT2 Remote file template example
This just copies the first file in the list, but it should give you what you need...