我的流程定义为
return IntegrationFlows.from(
(MessageSourceSpec<?, ? extends MessageSource<?>>) Files.inboundAdapter(directory)
.autoCreateDirectory(false)
.patternFilter("*.xml"),
e -> e.poller(Pollers.fixedDelay(1000)) ))
.transform(new TransformXmlToMyDocument())
.transform(new DataValidator()) // VALIDATOR
.transform(new TransformMyDocumentToRabbitDomain())
.channel(pubSubRabbitOutput)
.get();
问题是验证者。目前我作为&#34;透明&#34;如果消息中的数据无效,则抛出的变换器。整个流程将被包装在伪事务中以处理错误,如#34; how to move processed file to another directory using Spring integration ftp inbound adapter&#34;中所示。
但是在Flow中包含逻辑验证器的最佳方法是什么?它应该是变形剂还是其他种类的流动成分?
答案 0 :(得分:1)
有Filter EIP。当然,Spring Integration在这个问题上提供one。
您DataValidator
必须返回true/false
条件,并且您的弃牌逻辑有throw-exception-on-rejection
选项:
.filter(new DataValidator(), "validate", e -> e.throwExceptionOnRejection(true))