如果目标是在 Spring XML DSL 中使用谓词,那么这将更合适 -
<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>