This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Router Mediator
The Router Mediator is specifically designed for routing messages.
The Router Mediator can contain any number of routes. The 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 routing 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. Whereas 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.
Syntax
UI Configuration
The following properties are available:
Router Mediator
The Router Mediator has the following configuration options:
- Continue after routing - Whether to continue the routing if any of the child routes are executed.
- Yes
No
Tip
The default value is "No."
Number of clones - Shows you the number of child routes that router mediator has.
Note
You can add child routes by clicking the "Add Route" link in the right hand side of the text field.
Rote Configuration
Here are the options available in the Route Mediator configurations:
- Break After Route - Specifies whether to continue with the sibling routes or stop from the current route, if the routing condition is successful.
- Yes
- No
- Route Expression - An XPath expression to execute on the message
- Route Pattern - A regular expression to compare with the value retrieved from the above XPath expression.
Tip
You can click on this link to add namespaces if you are providing an expression. You will be provided another panel named "'Namespace Editor" where you can provide any number of namespace prefixes and URL that you have used in the XPath expression.
Target Configuration
Here you can prepare a message to send to an endpoint or mediate through some more sequences.
- SOAP Action - The SOAP action of the message.
- To Address - The target endpoint address.
- Sequence - Mediates the message through a sequence. You can either pick a named sequence from the registry or define an anonymous sequence by adding mediators to the current Target mediator as children.
- Endpoint - Sends the message to an endpoint. Here you can pick a named endpoint from the registry or keep the endpoint as anonymous.
Note
You can add in the Endpoint panel that can be accessed from the Manage-> Mediation-> Endpoints menu in the left hand side menu bar.
Note
You can configure the Mediator using XML. Click on "switch to source view" in the "Mediator" window.
Example
<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>
<router [continueAfter=(true | false)]> <route expression="xpath" [match="regEx"] [breakRouter=(true | false)]> <target [sequence="string"] [endpoint="string"]> <sequence ....../>? <endpoint ....../>? </target> </route>+ </router>