Sam
Sam

Reputation: 105

Spring Integration SFTP fetch daily but process immediately

I want to filter and fetch files daily and then process that all filtered files immediately.

here is my config;

 @Bean
public SftpInboundFileSynchronizer sftpInboundFileSynchronizer() {
    SftpInboundFileSynchronizer fileSynchronizer = new SftpInboundFileSynchronizer(sftpSessionFactory());
    fileSynchronizer.setRemoteDirectory(remoteDirectory);
    fileSynchronizer.setFilter(new SftpSimplePatternFileListFilter(downloadFilter));
    return fileSynchronizer;
}

@Bean
@InboundChannelAdapter(channel = "sftpChannel", poller = @Poller(cron = "0 0 0 * * ?"))
public MessageSource<File> sftpMessageSource() {
    SftpInboundFileSynchronizingMessageSource messageSource = new SftpInboundFileSynchronizingMessageSource(sftpInboundFileSynchronizer());
    messageSource.setLocalDirectory(new File(localDirectory));
    messageSource.setAutoCreateLocalDirectory(true);
    return messageSource;
}

and here is my file handler;

@ServiceActivator(inputChannel = "sftpChannel")
public void handle(File file) {
    log.info("file received . {}", file.getName());
}

it fetches the files daily and wait one day to call my handler for each of that fetched files. I want to consume that fetched files immediately. is it possible ? How can I do that?

Upvotes: 1

Views: 228

Answers (1)

Gary Russell
Gary Russell

Reputation: 174544

Increase maxMessagesPerPoll on the poller - it defaults to 1.

Or -1 means infinity (while unprocessed files are still present).

Upvotes: 1

Related Questions