2

I am using SftpSimplePatternFileListFilter and SftpPersistentAcceptOnceFileListFilter along with metadata store. But I noticed that it is not flushing the entries to file. I never show flush() method being called from PropertiesPersistingMetadataStore which ultimately invokes saveMetaData() method.

Here is my config looks like

<bean id="compositeFilter" class="org.springframework.integration.file.filters.CompositeFileListFilter">
    <constructor-arg>
        <list>
            <bean class="org.springframework.integration.sftp.filters.SftpSimplePatternFileListFilter">
                <constructor-arg value="*.txt" />
            </bean>
            <bean class="org.springframework.integration.sftp.filters.SftpPersistentAcceptOnceFileListFilter">
                <constructor-arg name="store" ref="metadataStore"/>
                <constructor-arg value="myapp"/>
            </bean>
        </list>
    </constructor-arg>
</bean>

<bean name="metadataStore" class="org.springframework.integration.metadata.PropertiesPersistingMetadataStore">
    <property name="baseDirectory" value="/tmp/"/>
</bean>
user509755
  • 2,941
  • 10
  • 48
  • 82

1 Answers1

1

By default PropertiesPersistingMetadataStore flushes to the file on applicationContext destroy:

@Override
public void close() throws IOException {
    flush();
}

@Override
public void flush() {
    saveMetadata();
}

@Override
public void destroy() throws Exception {
    flush();
}

Starting with 4.1.2 you can invoke flush() manually at runtime. E.g. periodically with <task:sheduled-tasks> or with some <int:outbound-channel-adapter>.

Feel free to ask for more information!

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118