Comment puis-je implémenter l'exemple de prédicat suivant donné au printemps 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();
3 Réponses :
Comme ceci:
<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>
Le contexte d'application de printemps n'a pas d'attribut de nom dans l'en-tête et
Quels sont vos versions de chameaux et de printemps?
En tout cas, vous pouvez essayer cela dans
La syntaxe sur celui-ci est fausse. Regardez la réponse de Dhiraj.
L'élément simple requis (voir réponse acceptée ) est
<simple>${header.type} == 'widget'</simple>
Si l'objectif est d'utiliser un prédicat dans le printemps XML DSL, cela serait plus approprié -
<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>