Router is specifically designed for what it name suggests. Routing messages.
Router mediator can contain any number of routes. Router mediator can be configured to continue or to stop the mediation after the routing by setting the 'continueAfter' attribute value to be 'true' and 'false' respectively. Each and every route must contain an 'expression' attribute which is to specify the XPath over which the roting condition is evaluated. Apart from that there can be an optional 'match' attribute as well. If both expression and the match attributes are specified in a particular route, the evaluated string value of the XPath over the current message will be compared with the regular expression provided as the value of the match attribute to see whether this route is matching for the current message. Where as if only the expression is specified, presence of the element specified by this XPath is considered as the routing condition.
One can configure a route to break routing or continue evaluating further routes to see any further matching by setting the 'breakRoute' attribute to 'true' or 'false' respectively. For all the routes there has to be a 'target' element which contains the information about the routing path as a sequence or an endpoint both can be inline as well as referred. If both an endpoint and a sequence is specified message will be first mediated through the sequence and sent to the endpoint after mediation. Particular target cannot contain an inline sequence and a referred sequence at the same time. The same applies to endpoint of the target as well.
<router [continueAfter=(true | false)]> <route expression="xpath" [match="regEx"] [breakRouter=(true | false)]> <target [sequence="string"] [endpoint="string"]> <sequence ....../>? <endpoint ....../>? </target> </route>+ </router>
Figure 1: Router Mediator
The router mediator has the following configuration options.
Route Mediator
Here are the options available in the Route mediator configurations.
<router> <route xmlns="http://ws.apache.org/ns/synapse" xmlns:ns1="http://org.apache.synapse/xsd" xmlns:ns="http://org.apache.synapse/xsd" expression="header/sourcefile/@name" match="esb*"> <target> <endpoint name="endpoint_urn_uuid_867AD5A624748DD63619739416601328-2078896617"> <default /> </endpoint> </target> </route> </router>