James
James

Reputation: 3184

Spring Integration - SFTP File Sync - Message is not generated when file name is same but time stamp is different

I've configured my application with a SftpInboundFileSynchronizingMessageSource. I would like a message to be received with file as the result payload whenever a new file is found (i.e. a new file name and / or time stamp). Here's what I have:

@Bean
public SftpInboundFileSynchronizer sftpInboundFileSynchronizer() {
    SftpInboundFileSynchronizer fileSynchronizer = new SftpInboundFileSynchronizer(sftpSessionFactory());
    fileSynchronizer.setDeleteRemoteFiles(false);
    fileSynchronizer.setRemoteDirectory(applicationProperties.getSftpDirectory());
    CompositeFileListFilter<ChannelSftp.LsEntry> compositeFileListFilter = new CompositeFileListFilter<ChannelSftp.LsEntry>();
    compositeFileListFilter.addFilter(new SftpPersistentAcceptOnceFileListFilter(store, "sftp"));
    compositeFileListFilter.addFilter(new SftpSimplePatternFileListFilter(applicationProperties.getLoadFileNamePattern()));
    fileSynchronizer.setFilter(compositeFileListFilter);
    fileSynchronizer.setPreserveTimestamp(true);
    return fileSynchronizer;
}

@Bean
@InboundChannelAdapter(autoStartup="true", channel = "sftpChannel", poller = @Poller("pollerMetadata"))
public SftpInboundFileSynchronizingMessageSource sftpMessageSource() {
    SftpInboundFileSynchronizingMessageSource source =
            new SftpInboundFileSynchronizingMessageSource(sftpInboundFileSynchronizer());
    source.setLocalDirectory(applicationProperties.getScheduledLoadDirectory());
    source.setAutoCreateLocalDirectory(true);
    CompositeFileListFilter<File> compositeFileFilter = new CompositeFileListFilter<File>();
    compositeFileFilter.addFilter(new LastModifiedFileListFilter());
    compositeFileFilter.addFilter(new FileSystemPersistentAcceptOnceFileListFilter(store, "dailyfilesystem"));
    source.setLocalFilter(compositeFileFilter);
    source.setCountsEnabled(true);
    return source;
}

This works great except for the scenario where on the subsequent poll I get the same file name with a different modified time stamp. In that case, I get a null result for the message. How can I ensure that a message is generated when the time stamp is the different but the file name is the same?

Upvotes: 1

Views: 624

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121282

Looks like your existing local copy (an old one) is busy somewhere downstream. The resource is open. And therefore an adapter can't override it.

Has been fixed recently: https://jira.spring.io/browse/INT-4305

Upvotes: 1

Related Questions