Java Spring SFTP集成偶发错误IOException:管道关闭

Java Spring SFTP集成偶发错误IOException:管道关闭,java,spring,spring-integration,sftp,Java,Spring,Spring Integration,Sftp,您好,我正在将SFTP版本5.1.6集成到我的spring boot应用程序中。下面是我正在使用的配置。但有时我会遇到异常情况,传输失败,不确定问题是什么,如何确保没有异常发生 上载文件时未能写入“TestFile.xml.writing”; 嵌套异常为org.springframework.core.NestedIOException:写入文件失败;嵌套 异常为4:java.io.IOException:Pipe closed 管道关闭 简单地说,这意味着出现了网络故障或服务器出于某种原因关闭

您好,我正在将SFTP版本5.1.6集成到我的spring boot应用程序中。下面是我正在使用的配置。但有时我会遇到异常情况,传输失败,不确定问题是什么,如何确保没有异常发生

上载文件时未能写入“TestFile.xml.writing”; 嵌套异常为org.springframework.core.NestedIOException:写入文件失败;嵌套 异常为4:java.io.IOException:Pipe closed

管道关闭

简单地说,这意味着出现了网络故障或服务器出于某种原因关闭了连接;您需要查看服务器日志以了解更多信息


您可以向出站适配器添加重试建议,以重试失败。

您能否进一步了解如何重试失败?请参阅。具体来说,配置@Bean并将其Bean名称添加到@ServiceAcivator的adviceChain中。
@Bean
public SessionFactory<ChannelSftp.LsEntry> sftpSessionFactory() {
    LOGGER.debug(" Creating SFTP Session Factory -Start");
    DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory(true);
    factory.setHost(sftpHost);
    factory.setPort(sftpPort);
    factory.setUser(sftpUser);
    factory.setPassword(sftpPasword);
    factory.setAllowUnknownKeys(true);
    LOGGER.debug(" Creating SFTP Session Factory -End");
    return new CachingSessionFactory<>(factory);
}

 @Bean
@ServiceActivator(inputChannel = "toSftpChannel")
public MessageHandler handler() {
    SftpMessageHandler handler = new SftpMessageHandler(sftpSessionFactory());
    LOGGER.debug(" Creating SFTP MessageHandler - Start ");

    handler.setRemoteDirectoryExpression(new LiteralExpression(sftpRemoteDirectory));
    handler.setFileNameGenerator(new FileNameGenerator() {
        @Override
        public String generateFileName(Message<?> message) {
            if (message.getPayload() instanceof File) {

                return ((File) message.getPayload()).getName();
            } else {
                throw new IllegalArgumentException("Expected Input is File.");
            }
        }
    });
    LOGGER.debug(" Creating SFTP MessageHandler - End ");
    return handler;
}

@MessagingGateway
public interface UploadGateway {
    @Gateway(requestChannel = "toSftpChannel")
    void sendToSftp(File file);
    }