Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A key aspect of the Message Router, and another difference with Pipes and Filters, is that it will not modify the contents of the message. It is only concerned with the destination for the message and not any transformations.

Message Router using XML DSL:

We can determine how to route a request from an input (direct:a) endpoint to either direct:x, direct:y, or direct:z depending on the evaluation of various criteria:

Code Block
languagexml
<route>
    <from uri="direct:a"/>
    <choice>
        <when>
            <simple>${header.action} == 'add'</simple>
            <to uri="direct:x"/>
        </when>
        <when>
            <simple>${header.action} == 'upsert'</simple>
            <to uri="direct:y"/>
        </when>
        <otherwise>
            <to uri="direct:z"/>
        </otherwise>
    </choice>
</route>