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

Mediation Sequences

A mediation sequence, commonly called a "sequence," is a tree of mediators. That means it can hold other mediators and execute them. When a message is delivered to a sequence, it sends the message through all its child mediators.

There are two types of sequences:

  • In-line Sequences
<sequence name="string">other mediators</sequence>

The in-line sequences have their child mediators defined inside the sequence itself.

  • Named Sequences
<sequence key="name"/>

The named sequences refer other sequences using a key. This allows reusing of sequences.

Sequences may be defined within the synapse.xml configuration or within the Registry. A mediation configuration holds two special sequences named "main" and "fault". The default "main" sequence will simply send a message without mediation, while the default "fault" sequence would log the message including the payload and any error/exception encountered and stop further processing.

  • Main Sequence
<syn:sequence name="main" xmlns:syn="http://ws.apache.org/ns/synapse">
      <syn:log/>
      <syn:drop/>
</syn:sequence>
  • Fault Sequence
<syn:sequence name="fault" xmlns:syn="http://ws.apache.org/ns/synapse">
      <syn:log level="full">
      <syn:property name="MESSAGE" value="Executing default&quot;fault&quot; sequence"/>
      <syn:property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
      <syn:property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
      </syn:log>
      <syn:drop/>
 </syn:sequence>

Refer to the list of available properties in Properties.

All the messages that are not for Proxy Services will be sent through the "main" sequence.

A sequence can have an error handler. Error handler is again another sequence. If an error occurs while executing a sequence, its error handler will be called. Every sequence has an error handler. If one is not explicitly specified, the fault sequence will be treated as the error handler. Refer to an example of error handling here.

Note

Message mediation always processes messages according to the mediation sequence defined as "main."