Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/389.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
Java Spring集成DSL SFTP良好实践_Java_Spring_Spring Integration_Sftp - Fatal编程技术网

Java Spring集成DSL SFTP良好实践

Java Spring集成DSL SFTP良好实践,java,spring,spring-integration,sftp,Java,Spring,Spring Integration,Sftp,我目前正在尝试使用SI DSL SFTP功能推送一些文件 我不能很流利地使用这个fwk,所以我想知道是否有更好的方法来实现我的目标 它是这样工作的,除了复制文件时,rest调用处于超时状态 奖励:有关于SI DSL的好读物(书籍或在线)吗? (咖啡馆si样品和参考品除外) 编辑: 该SI流程是否遵循SI良好实践 为什么我的rest调用以超时结束,尽管文件已正确复制到sftp服务器 Java配置: @Configuration @EnableIntegration @I

我目前正在尝试使用SI DSL SFTP功能推送一些文件

我不能很流利地使用这个fwk,所以我想知道是否有更好的方法来实现我的目标

它是这样工作的,除了复制文件时,rest调用处于超时状态

奖励:有关于SI DSL的好读物(书籍或在线)吗? (咖啡馆si样品和参考品除外)

编辑:

  • 该SI流程是否遵循SI良好实践
  • 为什么我的rest调用以超时结束,尽管文件已正确复制到sftp服务器
Java配置:

    @Configuration
    @EnableIntegration
    @IntegrationComponentScan
    public class IntegrationConfig {

        //flow gateway
        @MessagingGateway
        public interface FlowGateway {
            @Gateway(requestChannel = "SftpFlow.input")
            Collection<String> flow(Collection<File> name);

        }

        //sftp flow bean
        @Bean
        public IntegrationFlow SftpFlow() {
             return f -> f
                .split()
                .handle(Sftp.outboundAdapter(this.sftpSessionFactory(), FileExistsMode.REPLACE)
                        .useTemporaryFileName(false)
                        .remoteDirectory(sftpFolder));
        }

        //sftp session config
        @Bean
        public DefaultSftpSessionFactory sftpSessionFactory() {
            System.out.println("Create session");
            DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory(true);
            factory.setHost(sftpHost);
            factory.setPort(Integer.valueOf(sftpPort));
            factory.setUser(sftpUser);
            factory.setPassword(sftpPwd);
            factory.setAllowUnknownKeys(true);
            return factory;
        }

}
  • Spring集成JavaDSL完全基于Spring集成核心。因此,所有的概念、配方、文档、样本等也都在这里应用

  • 问题是什么?让我猜猜:“为什么它会超时和阻塞?”这对我来说很明显,因为我知道在哪里阅读,但对其他人来说可能不清楚。请下次再具体一点:有足够多的人可以用“不清楚”来结束你的问题

  • 那么,让我们来分析一下你拥有什么,以及为什么它不是你想要的

    Spring集成中的端点可以是单向的(
    Sftp.outboundAdapter()
    )或请求-应答的(
    Sftp.outboundGateway()
    )。当它是单向的时就不足为奇了,没有任何东西可以返回并继续流或发送回复,就像您的情况一样

    我确信您对回复不感兴趣,否则您使用了不同的端点

    .split()
    发送所有项目后,进程将完全停止,并且没有任何内容可发送回
    @Gateway
    ,正如您的代码所示:

    Collection<String> flow(Collection<File> name);
    
    .split()
    之后,将文件并行发送到SFTP


    另外,我不确定您还需要阅读什么,因为到目前为止,您的代码中的所有内容都很好,只是这个讨厌的
    回复问题。

    非常清晰的答案,正是我所期望的。我已根据你的评论编辑了我的问题。
    Collection<String> flow(Collection<File> name);
    
    .channel(c -> c.executor(taskExecutor()))