Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

There are two types of sequences:

  • In-line Sequences

...

Configuring a Mediation Sequence

You can define mediation sequences using the Management Console as described in Adding a Mediation Sequence. The underlying Synapse configuration uses the following syntax:

Code Block
languagehtml/xml
<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
Code Block
XMLXML
<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 [onError="string"] [key="string"] [trace="enable"] [statistics="enable"]>
    mediator*
</sequence>

You can list the mediators right in the sequence definition (referred to as an in-line sequence) and refer to other sequences by name. For example:

Code Block
languagehtml/xml
<sequence name="foo">
    <log/>
    <property name="test" value="test value"/>
      <syn:property name<sequence key="ERRORother_CODE" expression="get-property('ERROR_CODE')"sequence"/>
      <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.

...

<send/>
</sequence>

This sequence specifies three mediators in-line: the log mediator, property mediator, and the send mediator. It also references the named sequence "other_sequence" and therefore uses all the mediators defined in that sequence.

In addition to mediators and other sequences, you can configure the following:

  • Create a dynamic sequence by referring to an entry in the Registry, in which case the sequence will change as the registry entry changes.
  • Activate statistics collection by setting the statistics attribute to enable. In this mode the sequence will keep track of the number of messages processed and their processing times. For more information, see Monitoring the ESB.
  • Activate trace collection by setting the trace attribute to enable. If tracing is enabled on a sequence, all messages being processed through the sequence will write tracing information through each mediation step. For more information, see Mediation Tracer.
  • Use the onError attribute to define a custom error handler sequence. If an error occurs while executing

...

  • the sequence,

...

  • this error handler will be called.

...

  • If you do not specify an error handler

...

  • , the fault sequence will be

...

  • used, as described in the

...

titleNote

...

  • next section.

About the Main and Fault Sequences

A mediation configuration holds two special sequences named "main" and "fault". All messages that are not destined for Proxy Services are sent through the "main" sequence. By default, the "main" sequence simply sends a message without mediation, so to add message mediation, you add mediators and/or named sequences in the "main" sequence. By default, the "fault" sequence will log the message, the payload, and any error/exception encountered and will stop further processing. 

 

Excerpt
hiddentrue

General information about Mediation Sequences in WSO2 ESB.