The standard properties for an inbound channel adapter are pretty good, you can use a filename pattern or a regex to define which files are downloaded from the remote location. This is fine for a lot of situations, but sooner or later you will want to have more control over what files are downloaded.
The clever people at Spring have thought of this too and you can replace the filename pattern or regex with a filter property (filter=”myFilter”), this allows you to specify a class implementing org.springframework.integration.file.filters.FileListFilter, in this class you filter each file available on the remote server against whatever criteria you wish and then return the list of remote files back you want to download.
My first use for this was when accessing a remote server with read only access, we did not have permission to delete files when downloaded and as such each time the server was polled, all the existing files that met the filename pattern criteria were downloaded again. How to solve this? Maintain a list of downloaded files locally and check against this in the custom filter for the all the incoming files from the remote server.
Sample FTP inbound channel config:
<int-ftp:inbound-channel-adapter
channel="ftpChannel"
session-factory="ftpSessionFactory"
filter="customFilter"
local-directory="file:/my_transfers">
remote-directory="some/remote/path"
<int:poller fixed-rate="1000"/>
</int-ftp:inbound-channel-adapter>
Sample bean configuration for filter class
<bean id="customFilter" class="org.example.CustomFilter"/>
