根据此doc找不到正确的过程,以从远程SFTP重新下载本地删除的文件。

要求是删除已从远程SFTP获取的本地文件,并在需要时使用sftp-inbound-adapter(DSL configuration)重新获取该文件。在此实现中,MetadataStore尚未持久保存到任何外部系统中,例如PropertiesPersistingMetadataStore或Redis Metadata Store。因此,按照docMetadataStore存储在内存中。

无法找到任何方法从MetadataStore删除该远程文件的元数据,以使用file_name重新获取本地删除的文件。而且没有任何线索,应该如何实现此removeRemoteFileMetadata()回调(according to this doc)。

配置类包含以下内容:

    @Bean
    public IntegrationFlow fileFlow() {
        SftpInboundChannelAdapterSpec spec = Sftp.inboundAdapter(sftpConfig.getSftpSessionFactory())
                .preserveTimestamp(true)
                .patternFilter(Constants.FILE_NAME_CONVENTION)
                .remoteDirectory(sftpConfig.getSourceLocation())
                .autoCreateLocalDirectory(true)
                .deleteRemoteFiles(false)
                .localDirectory(new File(sftpConfig.getDestinationLocation()));

        return IntegrationFlows
                .from(spec, e -> e.id("sftpInboundAdapter").autoStartup(false)
                        .poller(Pollers.fixedDelay(5000).get()))
                .channel(MessageChannels.direct().get())
                .handle(message -> {
                    log.info("Fetching File : " + message.getHeaders().get("file_name").toString());
                })
                .get();
    }

最佳答案

使用ChainFileListFilterSftpSimplePatternFileListFilterSftpPersistentAcceptOnceFileListFilter

使用SimpleMetadataStore将状态存储在内存(或其他一些MetadataStore)中。

new SftpPersistentAcceptOnceFileListFilter(store, "somePrefix");

然后,store.remove(key)其中keysomePrefix + fileName

localFilterFileSystemPersistentAcceptOnceFileListFilter中使用类似的过滤器。

关于java - 使用SFTP入站重新下载本地删除的文件的过程是什么,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/62073217/

10-11 20:43
查看更多