I need to transfer the file from Local to multiple sftp server folders. This is my code so far, I'm transferring one to one basis with single channel:
private IntegrationFlow localToRemotePush(final String localDirectory,String remoteDirectory, String adapterName) {
return IntegrationFlows
.from(Files.inboundAdapter(Paths.get(localDirectory).toFile())
.regexFilter(FILE_PATTERN_REGEX)
.preventDuplicates(false),
e -> {
e.poller(Pollers.fixedDelay(getPollerIntervalMs())
.maxMessagesPerPoll(getMaxFetchSize())
.errorChannel("errorChannel")
.transactional(transactionManager)
.transactionSynchronizationFactory(mmPushSftpSyncFactory()) // moves processed files
).id(adapterName);
})
.handle(Sftp.outboundAdapter(mmPushSftpSessionFactory())
.remoteDirectory(getRemoteRootDir() + remoteDirectory1)
//.remoteDirectory(getRemoteRootDir() + remoteDirectory2) --- this way is correct ?
.temporaryFileSuffix(".tmp"))
.get();
}
Is it possible to transfer local files from one local folder to multiple sftp folders using single channel?