The Message Router from the EIP patterns allows you to consume from an input destination, evaluate some predicate then choose the right output destination.
The following example shows how to route a request from an input queue:a endpoint to either queue:b, queue:c or queue:d depending on the evaluation of various Predicate expressions
Using the Fluent Builders
{snippet:id=e3|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java} |
Using the Spring XML Extensions
{snippet:id=example|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/xml/buildSimpleRouteWithChoice.xml} |
If you use a choice
without adding an otherwise
, any unmatched exchanges will be dropped by default.