如果进程运行时间长或第二次运行该进程具有基于文件的元数据存储,则不会下载文件

时间:2019-06-19 13:51:17

标签: spring-integration spring-integration-sftp

我已经配置了缓存的会话工厂,并且我有sftp入站适配器, 这会下载文件一段时间,然后停止,即使在重新启动过程之后,它也只是挂起并且没有与sftp服务器建立JSCH会话

@Autowired
@Qualifier("cachedSftpSessionFactory")
private DefaultSftpSessionFactory defaultSftpSessionFactory;

@Bean(name="sessionFactoryCached")
public CachingSessionFactory getCachingSessionFactory(){
    CachingSessionFactory cachingSessionFactory = new CachingSessionFactory(defaultSftpSessionFactory,8);
    cachingSessionFactory.setTestSession(true);
    return cachingSessionFactory;
}

@Bean(name="SftpSessionFactory")
public DefaultSftpSessionFactory getDefaultSftpSessionFactory() throws Exception {
    DefaultSftpSessionFactory defaultSftpSessionFactory = new DefaultSftpSessionFactory();
    defaultSftpSessionFactory.setPort(port);
    defaultSftpSessionFactory.setHost(host);
    defaultSftpSessionFactory.setUser(user);
    defaultSftpSessionFactory.setPassword(password);
    defaultSftpSessionFactory.setProxy(getProxySOCKS5FactoryBean().getObject());
    defaultSftpSessionFactory.setSessionConfig(getPropertiesFactoryBean().getObject());
    return defaultSftpSessionFactory;
}

@Bean(name="sessionConfig")
public PropertiesFactoryBean getPropertiesFactoryBean(){
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    Properties properties = new Properties();
    properties.setProperty("StrictHostKeyChecking", "no");
    propertiesFactoryBean.setProperties(properties);
    return propertiesFactoryBean;
}

@Bean(name="proxySocks5")
public ProxySOCKS5FactoryBean getProxySOCKS5FactoryBean(){
    ProxySOCKS5FactoryBean proxySOCKS5FactoryBean = new ProxySOCKS5FactoryBean(proxyHost, proxyPort);
    return proxySOCKS5FactoryBean;
}

<bean id="remoteMetadataStore"        class="org.springframework.integration.metadata.PropertiesPersistingMetadataStore">
        <property name="baseDirectory" value="/externalSftpFolderMetadata"/>
        <property name="fileName" value="remoteMetadatastore.properties"/>
</bean>
<bean id="localFilter" class="org.springframework.integration.file.filters.AcceptAllFileListFilter"/>

<bean id="compositeCSVFilter" class="org.springframework.integration.file.filters.CompositeFileListFilter">
        <constructor-arg name="fileFilters">
            <list>
                <bean class="org.springframework.integration.sftp.filters.SftpRegexPatternFileListFilter">
                    <constructor-arg name="pattern" value=".*\.(csv|CSV)"/>
                </bean>
                <bean class="org.springframework.integration.sftp.filters.SftpPersistentAcceptOnceFileListFilter">
                    <constructor-arg name="store" ref="remoteMetadataStore"/>
                    <constructor-arg name="prefix" value="SftpService"/>
                    <property name="flushOnUpdate" value="true"/>
                </bean>
            </list>
        </constructor-arg>
</bean>

<int-sftp:inbound-channel-adapter
        id="ftpInboundAdapter"
        channel="ftpInputChannel"
        session-factory="cachedSftpSessionFactory"
        remote-directory="/data"
        local-directory="/externalSftpFolderSync"
        auto-create-local-directory="true"
        remote-file-separator="/"
        temporary-file-suffix=".writing"
        delete-remote-files="false"
        preserve-timestamp="true"
        local-filter="localFilter"
        filter="compositeCSVFilter"
        auto-startup="true">
    <int:poller fixed-rate="1000"/>
</int-sftp:inbound-channel-adapter>

我尝试过将int:poller fixed-rate =“ 1000”和testSession = true保持不变,但是这些都没有帮助。提及:-https://github.com/spring-projects/spring-integration/issues/2605https://docs.spring.io/spring-integration/docs/5.1.0.RELEASE/reference/html/sftp.html#sftp-jsch-logging

文件应按照在远程服务器上可用时的方式进行下载,这是一个长期运行的过程,并且我需要多个入站适配器,因为需要从远程服务器的多个目录下载文件,所有适配器都使用相同的通道并共享相同的cachedSessionFactory

0 个答案:

没有答案