Message Router

The Message Router from the EIP patterns allows you to consume from an input destination, evaluate some predicate, then choose the right output destination.


In Camel, the Message Router can be archived in different ways such as:

The Content-Based Router is recommended to use when you have multiple predicates to evaluate where to send the message.

The Routing Slip and Dynamic Router are arguably more advanced where you do not use predicates to choose where to route the message, but use an expression to choose where the message should go.


The following example shows how to route a request from an input direct:a endpoint to either direct:b, direct:c, or direct:d depending on the evaluation of various Predicates:

  • Java

  • XML

        .when(simple("${} == 'bar'"))
        .when(simple("${} == 'cheese'"))
    <from uri="direct:a"/>
            <simple>${} == 'bar'</simple>
            <to uri="direct:b"/>
            <simple>${} == 'cheese'</simple>
            <to uri="direct:c"/>
            <to uri="direct:d"/>