Search code examples
javaspring-integrationspring-integration-sftp

Re Read file when using int-sftp:inbound-channel-adapter


I have a int-sftp:inbound-channel-adapter which uses SftpPersistentAcceptOnceFileListFilter as part of a composite filter. Reading the documentation/ source code it should accept a file to be read again if the modified datetime has changed, but I cant get it to work, it only reads is the once. Im using redis as the store.

Any ideas what is wrong with the configuration, Im using spring integration 4.3.5

<int-sftp:inbound-channel-adapter id="sftpInboundAdapterCensus"
    channel="sftpInboundCensus"
    session-factory="sftpSessionFactory"
    local-directory="${sftp.localdirectory}/census-local"
    filter="censusCompositeFilter"
    remote-file-separator="/"
    remote-directory="${sftp.directory.census}">
    <int:poller cron="${sftp.cron}" max-messages-per-poll="1" error-channel="pollerErrorChannel"/>
</int-sftp:inbound-channel-adapter>

<bean id="censusCompositeFilter"
class="org.springframework.integration.file.filters.CompositeFileListFilter">
<constructor-arg>
 <list>
     <bean class="org.springframework.integration.sftp.filters.SftpSimplePatternFileListFilter">
         <constructor-arg value="*.xml" />
     </bean>
     <bean id="SftpPersistentAcceptOnceFileListFilter" class="org.springframework.integration.sftp.filters.SftpPersistentAcceptOnceFileListFilter">
         <constructor-arg ref="metadataStore" />
         <constructor-arg value="censusSampleLock_" />
     </bean>
 </list>
</constructor-arg>
</bean>

Solution

  • The SftpPersistentAcceptOnceFileListFilter only controls what we fetch from the server. You also need a FileSystemPersistentAcceptOnceFileListFilter in the local-filter (which determines which files that have been fetched end up being emitted as messages). The local filter is an AcceptOnceFileListFilter by default.