Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring integration Spring集成(SFTP):从子目录下载文件时出现问题_Spring Integration_Spring Integration Sftp - Fatal编程技术网

Spring integration Spring集成(SFTP):从子目录下载文件时出现问题

Spring integration Spring集成(SFTP):从子目录下载文件时出现问题,spring-integration,spring-integration-sftp,Spring Integration,Spring Integration Sftp,我在Spring引导应用程序中使用Spring集成版本5.4.4。 我需要从“server_sftp”目录下的子目录中获取所有XML文件。为此,我使用带有mget命令的SFTP流式入站通道适配器和SFTP出站网关。不幸的是,应用程序只从根目录(“server_sftp”)下载文件,而不从子目录下载文件 我哪里出错了 @Bean @InboundChannelAdapter(channel = "downloadXmlFileInputChannel", poller = @P

我在Spring引导应用程序中使用Spring集成版本5.4.4。 我需要从“server_sftp”目录下的子目录中获取所有XML文件。为此,我使用带有mget命令的SFTP流式入站通道适配器和SFTP出站网关。不幸的是,应用程序只从根目录(“server_sftp”)下载文件,而不从子目录下载文件

我哪里出错了

@Bean
@InboundChannelAdapter(channel = "downloadXmlFileInputChannel", poller = @Poller(fixedDelay = "300000"))
public MessageSource<InputStream> sftpXmlFileMessageSource() {
    SftpStreamingMessageSource messageSource = new SftpStreamingMessageSource(template());
    messageSource.setRemoteDirectory("server_sftp/");
    return messageSource;
}

@Bean
public IntegrationFlow xmlFilesReadingFlow() {
    return IntegrationFlows
            .from(sftpXmlFileMessageSource(), e -> e.poller(Pollers.fixedDelay(Duration.ofSeconds(5))))
            .handle(Sftp
                    .outboundGateway(template(), Command.MGET, "'server_sftp/*'")
                    .options(Option.RECURSIVE)
                    .autoCreateLocalDirectory(true)
                    .localDirectoryExpression("'../webapps/event_report_app-1.0/xmlFilesLocalDirectory/' + #remoteDirectory")
                    .localFilenameExpression("#remoteFileName.replaceFirst('sftpSource', 'localTarget')"))
            .channel("downloadXmlFileOutputChannel")
            .get();
}

@Bean
public PollableChannel downloadXmlFileInputChannel() {
    return new QueueChannel();
}

@Bean
public DirectChannel downloadXmlFileOutputChannel() {
    return new DirectChannel();
}
@Bean
@InboundChannelAdapter(channel=“downloadXmlFileInputChannel”,poller=@poller(fixedDelay=“300000”))
public MessageSource sftpXmlFileMessageSource(){
SftpStreamingMessageSource messageSource=新的SftpStreamingMessageSource(模板());
messageSource.setRemoteDirectory(“server_sftp/”);
返回消息源;
}
@豆子
公共集成流XmlFileReadingFlow(){
返回积分流
.from(sftpXmlFileMessageSource(),e->e.poller(Pollers.fixedDelay(持续时间秒(5)))
.手柄(Sftp
.outboundGateway(template(),Command.MGET,“'server_sftp/*”)
.options(Option.RECURSIVE)
.autoCreateLocalDirectory(true)
.localDirectoryExpression(“../webapps/event_report_app-1.0/xmlFilesLocalDirectory/”+#remoteDirectory”)
.localFilenameExpression(“#remoteFileName.replaceFirst('sftpSource','localTarget')”)
.channel(“下载XmlFileOutputChannel”)
.get();
}
@豆子
public PollableChannel下载XmlFileInputChannel(){
返回新的队列通道();
}
@豆子
公共DirectChannel下载XmlFileOutputChannel(){
返回新的DirectChannel();
}

使用带递归MGET命令的获取完整树

使用mget命令 mget基于模式检索多个远程文件,并支持以下选项:

-p:保留远程文件的时间戳

-R:递归地检索整个目录树

-x:如果没有与模式匹配的文件,则引发异常(否则,将返回空列表)

-D:成功传输后删除每个远程文件。如果忽略传输,则不会删除远程文件,因为FileExistsMode是IGNORE,而本地文件已经存在

mget操作产生的消息负载是一个列表对象(即,文件对象的列表,每个对象表示检索到的文件)