PropertiesPersistingMetadataStore 不写入文件

PropertiesPersistingMetadataStore not writing to file

我正在使用 SftpSimplePatternFileListFilter 和 SftpPersistentAcceptOnceFileListFilter 以及元数据存储。但我注意到它没有将条目刷新到文件中。我从不显示从最终调用 saveMetaData() 方法的 PropertiesPersistingMetadataStore 调用 flush() 方法。

这是我的配置

<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>

默认情况下 PropertiesPersistingMetadataStoreapplicationContext 销毁时刷新到文件:

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

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

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

4.1.2 开始,您可以在运行时手动调用 flush()。 例如。定期 <task:sheduled-tasks> 或一些 <int:outbound-channel-adapter>.

随时询问更多信息!