Chapter 8. Message Routing

download PDF


The message routing patterns describe various ways of linking message channels together. This includes various algorithms that can be applied to the message stream (without modifying the body of the message).

8.1. Content-Based Router


A content-based router, shown in Figure 8.1, “Content-Based Router Pattern”, enables you to route messages to the appropriate destination based on the message contents.

Figure 8.1. Content-Based Router Pattern

Content-based router pattern

Java DSL example

The following example shows how to route a request from an input, seda:a, endpoint to either seda:b, queue:c, or seda:d depending on the evaluation of various predicate expressions:
RouteBuilder builder = new RouteBuilder() {
    public void configure() {

XML configuration example

The following example shows how to configure the same route in XML:
<camelContext id="buildSimpleRouteWithChoice" xmlns="">
    <from uri="seda:a"/>
        <xpath>$foo = 'bar'</xpath>
        <to uri="seda:b"/>
        <xpath>$foo = 'cheese'</xpath>
        <to uri="seda:c"/>
        <to uri="seda:d"/>
Red Hat logoGithubRedditYoutubeTwitter


Try, buy, & sell


About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.