Fix (S)FTP Java/DSL Config

JIRA: https://jira.spring.io/browse/INT-4184

Polishing
This commit is contained in:
Gary Russell
2016-12-14 17:14:16 -05:00
committed by Artem Bilan
parent 4e5d9016b3
commit cc9d825fb0
2 changed files with 18 additions and 14 deletions

View File

@@ -430,13 +430,13 @@ public class FtpJavaApplication {
public FtpInboundFileSynchronizer ftpInboundFileSynchronizer() { public FtpInboundFileSynchronizer ftpInboundFileSynchronizer() {
FtpInboundFileSynchronizer fileSynchronizer = new FtpInboundFileSynchronizer(ftpSessionFactory()); FtpInboundFileSynchronizer fileSynchronizer = new FtpInboundFileSynchronizer(ftpSessionFactory());
fileSynchronizer.setDeleteRemoteFiles(false); fileSynchronizer.setDeleteRemoteFiles(false);
fileSynchronizer.setRemoteDirectory("/"); fileSynchronizer.setRemoteDirectory("foo");
fileSynchronizer.setFilter(new FtpSimplePatternFileListFilter("*.xml")); fileSynchronizer.setFilter(new FtpSimplePatternFileListFilter("*.xml"));
return fileSynchronizer; return fileSynchronizer;
} }
@Bean @Bean
@InboundChannelAdapter(channel = "ftpChannel") @InboundChannelAdapter(channel = "ftpChannel", poller = @Poller(fixedDelay = "5000"))
public MessageSource<File> ftpMessageSource() { public MessageSource<File> ftpMessageSource() {
FtpInboundFileSynchronizingMessageSource source = FtpInboundFileSynchronizingMessageSource source =
new FtpInboundFileSynchronizingMessageSource(ftpInboundFileSynchronizer()); new FtpInboundFileSynchronizingMessageSource(ftpInboundFileSynchronizer());
@@ -483,11 +483,13 @@ public class FtpJavaApplication {
return IntegrationFlows return IntegrationFlows
.from(s -> s.ftp(this.ftpSessionFactory) .from(s -> s.ftp(this.ftpSessionFactory)
.preserveTimestamp(true) .preserveTimestamp(true)
.remoteDirectory("ftpSource") .remoteDirectory("foo")
.regexFilter(".*\\.txt$") .regexFilter(".*\\.txt$")
.localFilename(f -> f.toUpperCase() + ".a") .localFilename(f -> f.toUpperCase() + ".a")
.localDirectory(new File("d:\ftp_files")), .localDirectory(new File("d:\\ftp_files")),
e -> e.id("ftpInboundAdapter").autoStartup(false)) e -> e.id("ftpInboundAdapter")
.autoStartup(true)
.poller(Pollers.fixedDelay(5000)))
.handle(m -> System.out.println(m.getPayload())) .handle(m -> System.out.println(m.getPayload()))
.get(); .get();
} }

View File

@@ -469,17 +469,17 @@ public class SftpJavaApplication {
public SftpInboundFileSynchronizer sftpInboundFileSynchronizer() { public SftpInboundFileSynchronizer sftpInboundFileSynchronizer() {
SftpInboundFileSynchronizer fileSynchronizer = new SftpInboundFileSynchronizer(sftpSessionFactory()); SftpInboundFileSynchronizer fileSynchronizer = new SftpInboundFileSynchronizer(sftpSessionFactory());
fileSynchronizer.setDeleteRemoteFiles(false); fileSynchronizer.setDeleteRemoteFiles(false);
fileSynchronizer.setRemoteDirectory("/"); fileSynchronizer.setRemoteDirectory("foo");
fileSynchronizer.setFilter(new SftpSimplePatternFileListFilter("*.xml")); fileSynchronizer.setFilter(new SftpSimplePatternFileListFilter("*.xml"));
return fileSynchronizer; return fileSynchronizer;
} }
@Bean @Bean
@InboundChannelAdapter(channel = "sftpChannel") @InboundChannelAdapter(channel = "sftpChannel", poller = @Poller(fixedDelay = "5000"))
public MessageSource<File> sftpMessageSource() { public MessageSource<File> sftpMessageSource() {
SftpInboundFileSynchronizingMessageSource source = SftpInboundFileSynchronizingMessageSource source =
new SftpInboundFileSynchronizingMessageSource(sftpInboundFileSynchronizer()); new SftpInboundFileSynchronizingMessageSource(sftpInboundFileSynchronizer());
source.setLocalDirectory(new File("ftp-inbound")); source.setLocalDirectory(new File("sftp-inbound"));
source.setAutoCreateLocalDirectory(true); source.setAutoCreateLocalDirectory(true);
source.setLocalFilter(new AcceptOnceFileListFilter<File>()); source.setLocalFilter(new AcceptOnceFileListFilter<File>());
source.setMaxFetchSize(1); source.setMaxFetchSize(1);
@@ -521,12 +521,14 @@ public class SftpJavaApplication {
public IntegrationFlow sftpInboundFlow() { public IntegrationFlow sftpInboundFlow() {
return IntegrationFlows return IntegrationFlows
.from(s -> s.sftp(this.sftpSessionFactory) .from(s -> s.sftp(this.sftpSessionFactory)
.preserveTimestamp(true) .preserveTimestamp(true)
.remoteDirectory("sftpSource") .remoteDirectory("foo")
.regexFilter(".*\\.txt$") .regexFilter(".*\\.txt$")
.localFilenameExpression("#this.toUpperCase() + '.a'") .localFilenameExpression("#this.toUpperCase() + '.a'")
.localDirectory(this.sftpServer.getTargetLocalDirectory()), .localDirectory(new File("sftp-inbound")),
e -> e.id("sftpInboundAdapter").autoStartup(false)) e -> e.id("sftpInboundAdapter")
.autoStartup(true)
.poller(Pollers.fixedDelay(5000)))
.handle(m -> System.out.println(m.getPayload())) .handle(m -> System.out.println(m.getPayload()))
.get(); .get();
} }