Guide to Content-based Router (Message Routing)

A Content-based Router integration pattern will allow us to route messages to one or more destinations based on the contents of the message. For example, when an order is received we need to check the inventory for each product on the order across multiple warehouse systems, then this would be a good candidate for this type of pattern.

 

Content-based 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:

 

<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>

Â