Skip to content

Watch multiple Remote SFTP directories #1980

Description

@ulmermark

I am looking for solution/example that points me to how to watch multiple SFTP remote directories....

currently using a Spring Boot application with an @Configuration class that watches a single directory as such:

   @Bean
    public SftpInboundFileSynchronizer sftpInboundFileSynchronizer() throws Exception {
        SftpInboundFileSynchronizer fileSynchronizer = new SftpInboundFileSynchronizer(sftpSessionFactory());
        fileSynchronizer.setDeleteRemoteFiles(false);
        fileSynchronizer.setRemoteDirectory(this.serviceProps.getSftp().getRead().getRemoteDirectory());
        fileSynchronizer.setFilter(new SftpSimplePatternFileListFilter(this.serviceProps.getSftp().getRead().getRemotePattern()));
        return fileSynchronizer;
    }
    
    /**
     * Inbound Message Handler for files retrieved from the SFTP server
     * @return
     * @throws Exception
     */
    @Bean
    @InboundChannelAdapter(channel = "spn.vendor.gateway.sftp.inbound.channel")
    public MessageSource<File> sftpMessageSource() throws Exception {
        SftpInboundFileSynchronizingMessageSource source =
                new SftpInboundFileSynchronizingMessageSource(sftpInboundFileSynchronizer());
        source.setLocalDirectory(new File(this.serviceProps.getSftp().getRead().getLocalDirectory()));
        source.setAutoCreateLocalDirectory(true);
        
        FileSystemPersistentAcceptOnceFileListFilter localFilter = new FileSystemPersistentAcceptOnceFileListFilter(new RedisMetadataStore(this.redis), "spn-vendor-gateway-svc");
        
        Collection<FileListFilter<File>> filters = new ArrayList<>();
		filters.add(localFilter);
        CompositeFileListFilter<File> composite = new CompositeFileListFilter<File>(filters);
        
        source.setLocalFilter(composite); // TODO - need to use persistent a distributed Redis AcceptOnceFileFilter...
        return source;
    }

I do not see a way to instantiate multiple SftpInboundFileSynchronizer and MessageSource<File> instances all tied to the same input channel using the @Bean annotations.

Thanks for any help that can be given on this.

Mark

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions