Ce contenu n'est pas disponible dans la langue sélectionnée.
A.4. Content-based Router
Overview Copier lienLien copié sur presse-papiers!
Figure A.1. Content-based Router Pattern
Example ServiceMix EIP route Copier lienLien copié sur presse-papiers!
test:echo element is present in the message body, the message is routed to the http://test/pipeline/endpoint endpoint. Otherwise, the message is routed to the test:recipients endpoint.
Example A.1. ServiceMix EIP Content-based Route
<eip:content-based-router service="test:router" endpoint="endpoint">
<eip:rules>
<eip:routing-rule>
<eip:predicate>
<eip:xpath-predicate xpath="count(/test:echo) = 1" namespaceContext="#nsContext" />
</eip:predicate>
<eip:target>
<eip:exchange-target uri="endpoint:test:pipeline:endpoint" />
</eip:target>
</eip:routing-rule>
<eip:routing-rule>
<!-- There is no predicate, so this is the default destination -->
<eip:target>
<eip:exchange-target service="test:recipients" />
</eip:target>
</eip:routing-rule>
</eip:rules>
</eip:content-based-router>
Equivalent Apache Camel XML route Copier lienLien copié sur presse-papiers!
Example A.2. Apache Camel Content-based Router Using XML Configuration
<route>
<from uri="jbi:endpoint:http://progress.com/demos/test/router/endpoint"/>
<choice>
<when>
<xpath>count(/test:echo) = 1</xpath>
<to uri="jbi:endpoint:http://progress.com/demos/test/pipeline/endpoint"/>
</when>
<otherwise>
<!-- This is the default destination -->
<to uri="jbi:service:http://progress.com/demos/test/recipients"/>
</otherwise>
</choice>
</route>
Equivalent Apache Camel Java DSL route Copier lienLien copié sur presse-papiers!
Example A.3. Apache Camel Content-based Router Using Java DSL
from("jbi:endpoint:http://progress.com/demos/test/router/endpoint").
choice().when(xpath("count(/test:echo) = 1")).to("jbi:endpoint:http://progress.com/demos/test/pipeline/endpoint").
otherwise().to("jbi:service:http://progress.com/demos/test/recipients");