This documentation is for WSO2 ESB version 4.0.3. View documentation for the latest release.

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 specifies 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. This will check whether the route matches the current message. Whereas if only the expression is specified, the presence of the element specified by the XPath is considered as the routing condition.

One can configure a route to break routing or continue evaluating further routes to see further matches by setting the breakRoute attribute to true or false respectively. For all the routes, there has to be a target element which contains information about the routing path as a sequence or an endpoint. Both can be inline as well as referred. If both are endpoints and a sequence is specified, the message will be first mediated through the sequence and sent to the endpoint after mediation. A particular target cannot contain an inline sequence and a referred sequence at the same time. The same applies to an endpoint of the target as well.



Syntax

<router [continueAfter=(true | false)]>
  <route expression="xpath" [match="regEx"] [breakRouter=(true | false)]>
    <target [sequence="string"] [endpoint="string"]>
      <sequence ....../>?
      <endpoint ....../>?
    </target>
  </route>+
</router>

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.

Target Configuration

Here you can prepare a message to be sent to an endpoint or mediated 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>