具有 Spring 集成流的多个过滤器表达式
Multiple Filter Expression with Spring Integration Flow
我正在使用 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 类型的文件并获取其余文件。
您可以改用 .regexFilter
。
".*\.(xml|csv)"
或
.filterExpression("name.endsWith('.csv') OR name.endsWith('xml')")
或
.filterExpression("!name.endsWith('.txt')")
我正在使用 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 类型的文件并获取其余文件。
您可以改用 .regexFilter
。
".*\.(xml|csv)"
或
.filterExpression("name.endsWith('.csv') OR name.endsWith('xml')")
或
.filterExpression("!name.endsWith('.txt')")