[英]Camel Predicate Example in xml DSL
How can I implement following Predicate Example given in Spring DSL:如何实现 Spring DSL 中给出的以下谓词示例:
Predicate isWidget = header("type").isEqualTo("widget");
from("jms:queue:order")
.choice()
.when(isWidget).to("bean:widgetOrder")
.when(isWombat).to("bean:wombatOrder")
.otherwise()
.to("bean:miscOrder")
.end();
Like this:像这样:
<route>
<from uri="jms:queue:order"/>
<choice>
<when>
<simple>${header.type} == 'widget'</simple>
<to uri="bean:widgetOrder"/>
</when>
<when>
<simple>${header.type} == 'wombat'</simple>
<to uri="bean:wombatOrder"/>
</when>
<otherwise>
<to uri="bean:miscOrder"/>
</otherwise>
</choice>
</route>
The required simple element (see accepted answer ) is所需的简单元素(请参阅接受的答案)是
<simple>${header.type} == 'widget'</simple>
Notice how the field expression is surrounded by ${} followed by OGNL syntax for comparison, which is not part of the field expression itself.注意字段表达式是如何被 ${} 包围的,然后是用于比较的 OGNL 语法,这不是字段表达式本身的一部分。
IF the objective is to make use of a Predicate in Spring XML DSL then this would be more appropriate -如果目标是在 Spring XML DSL 中使用 Predicate 那么这会更合适 -
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<camel:camelContext trace="true">
<camel:route>
<camel:from uri="jms:queue:order" />
<camel:filter>
<camel:method ref="myPredicate" />
<to uri="bean:widgetOrder"/>
</camel:filter>
</camel:route>
</camel:camelContext>
<bean id="myPredicate" class="MyPredicate"/>
</beans>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.