gpt4 book ai didi

java - Spring 集成 Java DSL : Remote filter is not applied on handle method

转载 作者:行者123 更新时间:2023-12-04 10:53:03 24 4
gpt4 key购买 nike

我想从 SFTP 服务器读取特定文件,并且只获取一次压缩文件。
我在处理消息时遇到问题,因为在远程服务器上定义的过滤器似乎没有应用于 handle 方法。

依赖项:

  • SpringBoot:2.2.1
  • Spring 集成:5.2.1
  • Spring 集成-jdbc:5.2.1
  • Spring 集成-sftp:5.2.1
  •     public IntegrationFlow buildSftpInboundIntegrationFlow() {
    return IntegrationFlows
    .from(
    Sftp
    .inboundStreamingAdapter(buildSftpRemoteFileTemplate())
    .remoteDirectory(getRemoteDirectoryPath())
    .filter(buildRemoteFileFilter())
    .remoteFileSeparator(
    Optional
    .ofNullable(getRemoteFileSeparator())
    .orElse(DEFAULT_REMOTE_PATH_SEPARATOR))
    .maxFetchSize(
    Optional.ofNullable(getMaxFetchSize()).orElse(DEFAULT_MAX_FETCH_SIZE)),
    sourcePollingChannelAdapterSpec -> sourcePollingChannelAdapterSpec
    .id(getSftpInboundStreamingAdapterIdentifier())
    .autoStartup(true)
    .poller(buildPollerSpec()))
    .handle(handleMessage())
    .get();
    }

    /**
    * Allows to build a regex to filter files.
    *
    * @return a regex as a {@link String}.
    */
    private String buildRegexFileFilter() {
    return String.format(".*\\.%s", getFileExtensionToFilter());
    }

    /**
    * Allows to build an instance of {@link SftpRemoteFileTemplate}.
    *
    * @return an instance of {@link SftpRemoteFileTemplate}.
    */
    private SftpRemoteFileTemplate buildSftpRemoteFileTemplate() {
    final SftpRemoteFileTemplate sftpRemoteFileTemplate = new SftpRemoteFileTemplate(getSftpSessionFactory());
    sftpRemoteFileTemplate.setAutoCreateDirectory(true);

    return sftpRemoteFileTemplate;
    }

    /**
    * Allows to build the filters to apply to the remote files.
    *
    * @return an instance of {@link CompositeFileListFilter}.
    */
    @SuppressWarnings("resource")
    private CompositeFileListFilter<LsEntry> buildRemoteFileFilter() {
    return new ChainFileListFilter<LsEntry>() // NOSONAR
    .addFilters(
    new SftpRegexPatternFileListFilter(buildRegexFileFilter()),
    getSftpPersistentAcceptOnceFileListFilter());
    }

    /**
    * Allows to build the poller specifications.
    *
    * @return an instance of {@link PollerSpec}.
    */
    private PollerSpec buildPollerSpec() {
    return Pollers
    .fixedDelay(
    Optional.ofNullable(getPollerDelayInSeconds()).orElse(DEFAULT_POLLER_DELAY_IN_SECONDS),
    TimeUnit.SECONDS)
    .transactional()
    .transactionSynchronizationFactory(getTransactionSynchronizationFactory());
    }
    ...


    你有什么想法可以推荐给我吗?
    为什么在处理方法中我收到远程过滤器应该排除的文件?
    这是一个错误?如何获得过滤的消息?

    最佳答案

    这是版本 5.2.1 中的模块 spring-integration 和 spring-integration-sftp 中的一个错误。
    它通过在版本 5.2.2 中升级这些依赖项来工作。 (2019 年 12 月 6 日)

    关于java - Spring 集成 Java DSL : Remote filter is not applied on handle method,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59374086/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com