Apache骆驼:使用()中使用复合条件
我正在使用Apache骆驼DSL路由,并且想检查身体是否不是null
,并且主体不包含像身份验证失败
的子字符串。在Java中类似:
if(body != null && !body.contains("authenticate failed")) {
//Do something.
}
Apache Camel DSL:
.choice()
.when(body().contains("authenticate failed"))
.log("after choice body().contains('authenticate failed') body: ${body}")
.when(body().isNotNull()) //Here I want to add the addiontional condition to this when `body not contains authenticate failed`.
如何编写这样的条件?在过程方法中鉴定对象并写下我的案例?
I am using Apache Camel DSL route and want to check if the body is not null
and body does not contains substring like authenticate failed
. In java something like:
if(body != null && !body.contains("authenticate failed")) {
//Do something.
}
Apache Camel DSL:
.choice()
.when(body().contains("authenticate failed"))
.log("after choice body().contains('authenticate failed') body: ${body}")
.when(body().isNotNull()) //Here I want to add the addiontional condition to this when `body not contains authenticate failed`.
How can I write a condition like this? predicates objects in the process method and write tin my case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用peedicateBuilder创建漂亮的复合谓词。这是如何做简单的身体的示例,不是用谓词构建器进行空白或空检查。
没有,或者可以将谓词作为参数甚至其他复合谓词列表,这使人们可以做出一些相当复杂的复合谓词。但是,当使用peedicateBuilder开始变得过于冗长时,只需使用处理器或Bean就可以抽象一些复杂性。
You can use PredicateBuilder to create pretty composite predicates. Here's example how to do simple Body is not null or empty check with PredicateBuilder.
Not and Or can take lists of predicates as arguments or even other composite predicates which allows one to make some fairly complex composite predicates. However when using PredicateBuilder starts to get overly verbose it's good to just use processor or bean instead to abstract away some of the complexity.