Unable to cache SFTP connection with Spring Integration

醉酒当歌 提交于 2020-01-25 01:35:49

问题


I need to transfer several small files via SFTP using spring integration, so I'd like to reuse a connection once established to avoid the overhead of creating a new one for every single message.

This is my current configuration:

<bean id="sftpTARGETSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
    <constructor-arg name="isSharedSession" value="true"/>
    <property name="host" value="${TARGET.push.host}"/>
    <property name="user" value="${TARGET.push.user}"/>
    <property name="privateKey" value="classpath:${TARGET.push.keyFile}"/>
    <property name="privateKeyPassphrase" value="${TARGET.push.keyFilePass}"/>
</bean>

<bean id="cachingSessionFactory"
    class="org.springframework.integration.file.remote.session.CachingSessionFactory">
    <constructor-arg ref="sftpTARGETSessionFactory"/>
    <property name="poolSize" value="2"/>
    <property name="sessionWaitTimeout" value="2000"/>
</bean>

<int-sftp:outbound-channel-adapter 
    id="sftpTARGET"
    session-factory="cachingSessionFactory"
    channel="ftpTARGET.channel"
    charset="UTF-8"
    remote-file-separator="/"
    remote-directory="${TARGET.push.path}"
    mode="REPLACE"/>

Unfortunately this doesn't work as I expected: every message opens a new ssh connection.

any hint on what's going wrong?

Using spring-integration 4.1.6 here.

thanks!

来源:https://stackoverflow.com/questions/32114088/unable-to-cache-sftp-connection-with-spring-integration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!