【发布时间】:2019-01-15 17:58:56
【问题描述】:
我需要将文件从本地传输到多个 sftp 服务器文件夹。 到目前为止,这是我的代码,我正在使用单通道一对一传输:
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();
}
是否可以使用单通道将本地文件从一个本地文件夹传输到多个 sftp 文件夹?
【问题讨论】:
标签: java spring-integration sftp spring-integration-sftp