【问题标题】:CachingSessionFactory setPoolSize() takes much longer after upgrading spring boot from 2.2.1.RELEASE to 2.3.1.Release将 Spring Boot 从 2.2.1.RELEASE 升级到 2.3.1.Release 后,CachingSessionFactory setPoolSize() 需要更长的时间
【发布时间】:2020-09-02 12:41:33
【问题描述】:

在我们的一项服务中,我们使用 spring 集成框架将一些文件发送到 FTP 服务器。为此,我们通过以下方式创建一个 CachingSessionFactory

SessionFactory<?> factory = getSessionFactory(properties);
CachingSessionFactory cachingSessionFactory = new CachingSessionFactory<>(factory);
cachingSessionFactory.setSessionWaitTimeout(properties.getTimeout());
cachingSessionFactory.setPoolSize(5);
createDirectories(cachingSessionFactory, properties);

properties 是我们注入并由我们创建的一些@ConfigurationProperties。 GetSessionFactory() 也是由我们完成的,但我不确定这是否相关。

在我们从 spring boot 2.2.1.Release 更新到 2.3.1.Release 之后,我们在服务启动时会出现巨大的性能损失。 设置池大小似乎存在问题,但我无法弄清楚它是什么。调试时,我看到进程在 setPoolSize(5) 步骤中永远挂起。

【问题讨论】:

    标签: java spring-boot ftp


    【解决方案1】:

    您可以尝试使用 - DefaultFtpSessionFactory 而不是 CachingSessionFactory DefaultFtpSessionFactory 不需要那个池来工作。

    【讨论】:

      【解决方案2】:

      我深入研究了底层类,发现 setPoolSize() 比预期的要重。特别是,它需要获得一些锁定,在我的情况下,这似乎会导致性能损失。我没有找到真正的根本原因,但我有一种方便的方法可以通过直接通过构造函数设置池大小来解决这个问题。这样,它就可以正确创建,并且不需要弄乱现有的。这条线成功了

      CachingSessionFactory cachingSessionFactory = new CachingSessionFactory<>(factory,5);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-06-01
        • 2023-04-07
        • 1970-01-01
        • 2021-10-15
        • 1970-01-01
        • 1970-01-01
        • 2021-12-22
        • 2021-09-06
        相关资源
        最近更新 更多