Two MessageSelector
implementations are provided,
BooleanTestXPathMessageSelector
and StringValueTestXPathMessageSelector
.
BooleanTestXPathMessageSelector
requires an XPathExpression which evaluates to a boolean,
for example boolean(/one/two) which will only select messages which have an element named
two which is a child of a root element named one. StringValueTestXPathMessageSelector
evaluates any XPath expression as a String
and compares the result with the provided value.
<!-- Interceptor which rejects messages that do not have a root element order --> <bean id="orderSelectingInterceptor" class="org.springframework.integration.channel.interceptor.MessageSelectingInterceptor"> <constructor-arg> <bean class="org.springframework.integration.xml.selector.BooleanTestXPathMessageSelector"> <constructor-arg value="boolean(/order)" /> </bean> </constructor-arg> </bean> <!-- Interceptor which rejects messages that are not version one orders --> <bean id="versionOneOrderSelectingInterceptor" class="org.springframework.integration.channel.interceptor.MessageSelectingInterceptor"> <constructor-arg> <bean class="org.springframework.integration.xml.selector.StringValueTestXPathMessageSelector"> <constructor-arg value="/order/@version" index="0"/> <constructor-arg value="1" index="1"/> </bean> </constructor-arg> </bean>