Файл не загружается, если процесс выполняется долго или второй раз запускается с хранилищем метаданных на основе файла - PullRequest
0 голосов
/ 19 июня 2019

Я настроил кешированную фабрику сеансов и у меня есть входящий адаптер sftp, он загружает файл на некоторое время, затем останавливается, даже после перезапуска процесса он просто зависает и не устанавливает сеанс JSCH с сервером sftp

@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/2605, https://docs.spring.io/spring-integration/docs/5.1.0.RELEASE/reference/html/sftp.html#sftp-jsch-logging

файл должен быть загружен так, как если бы он был доступен на удаленном сервере, это длительный процесс, и у меня есть несколько входящих адаптеров, так как нужно загружать файл с несколькихкаталог с удаленного сервера, все адаптеры используют один канал и совместно используют один и тот же cachedSessionFactory.

...