[英]Spring Integration - How to use SpEL to filter message on an annotation base?
我在Spring Integration参考页面上阅读了基于xml的配置:
<filter expression="#jsonPath(payload,'$..book[2].isbn') matches '\d-\d{3}-\d{5}-\d'"/>
什么是基于注释的等效项? 这样我就可以将SpEL用作过滤消息的逻辑。
谢谢。
您可以使用Java DSL ...
@Bean
public IntegrationFlow filteringFlow() {
return IntegrationFlows.from("someChannel")
.filter("#jsonPath(...) matches ...")
.channel("outChannel")
.get();
}
或使用bean配置它...
@Bean
@ServiceActivator(inputChannel = "someChannel")
public MessageHandler filter() {
MessageFilter filter = new MessageFilter(selector());
filter.setOutputChannelName("outChannel");
return filter;
}
@Bean
public MessageSelector selector() {
return new ExpressionEvaluatingSelector("#jsonPath(...) matches ...");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.