【问题标题】:Multiple Filter Expression with Spring Integration Flow使用 Spring Integration Flow 的多个过滤器表达式
【发布时间】:2019-04-05 09:45:03
【问题描述】:

我正在使用 Spring 集成流程,我知道如何添加过滤器表达式

IntegrationFlows.from(Sftp.inboundAdapter(inboundSftp)
            .localDirectory(this.getlocalDirectory(config.getId()))
            .deleteRemoteFiles(true)
            .filterExpression(config.getFilterExpression())
            .autoCreateLocalDirectory(true)
            .remoteDirectory(config.getInboundDirectory()), e -> e.poller(Pollers.cron(config.getCron()).errorChannel(MessageHeaders.ERROR_CHANNEL).errorHandler((ex) -> {
           // action on exceptions are here
        }))).publishSubscribeChannel(s -> s
            .subscribe(f -> f
                .handle(Sftp.outboundAdapter(outboundSftp)
                        .useTemporaryFileName(false)
                        .autoCreateDirectory(true)
                        .remoteDirectory(config.getOutboundDirectory()), c -> c.advice(startup.deleteFileAdvice())
                ))
            .subscribe(f -> f
                .handle(m -> {
                    // all my custom logging logic is here
                })
            ))
            .get();

我想了解的。

  • 如何给出多个过滤器表达式,例如我想从服务器获取 .csv 和 .xml 文件。
  • 如何忽略单个文件类型,例如,我只想忽略 .txt 类型的文件并获取其余文件。

【问题讨论】:

    标签: spring-integration spring-integration-dsl spring-integration-sftp


    【解决方案1】:

    您可以改用.regexFilter

    ".*\\.(xml|csv)"

    .filterExpression("name.endsWith('.csv') OR name.endsWith('xml')")

    .filterExpression("!name.endsWith('.txt')")

    【讨论】:

      猜你喜欢
      • 2011-09-29
      • 2019-07-20
      • 2015-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-27
      相关资源
      最近更新 更多