This is the latest release in the 6.x.x family. For EI 7.0.0, click here.

All docs This doc
Skip to end of metadata
Go to start of metadata

A mediator is the basic message processing unit and a fundamental part the ESB profile. A mediator can take a message, carry out some predefined actions on it, and output the modified message. For example, the Clone mediator splits a message into several clones, the Send mediator sends the messages, and the Aggregate mediator collects and merges the responses before sending them back to the client. 

The ESB profile ships with a range of mediators capable of carrying out various tasks on input messages, including functionality to match incompatible protocols, data formats and interaction patterns across different resources. Data can be split, cloned, aggregated, and enriched, allowing the ESB profile to match the different capabilities of services. XQuery and XSLT allow rich transformations on the messages. Rule-based message mediation allows users to cope with the uncertainty of business logic. Content-based routing using XPath filtering is supported in different flavors, allowing users to get the most convenient configuration experience. Built-in capability to handle Transactions allows message mediation to be done transactionally inside the ESB profile. With the eventing capabilities of the ESB profile, EDA based components can be easily interconnected, allowing the ESB profile to be used in the front-end of an organisation's SOA infrastructure.

A mediator is a full-powered processing unit in the ESB profile of WSO2 EI. At run-time, a mediator has access to all the parts of the ESB profile along with the current message and can do virtually anything with the message. At the run-time, a message is injected in to the mediator with the ESB profile information. Then this mediator can do virtually anything with the message. A user can write a mediator and put it into the ESB profile. This custom mediator and any other built-in mediator will be exactly the same as the API and the privileges (Refer to more information in Creating Custom Mediators).

A mediation sequence, commonly called a "sequence", is a list of mediators. That means, it can hold other mediators and execute them. It is part of the ESB profile's core and message mediation cannot live without this mediator. When a message is delivered to a sequence, it sends the message through all its child mediators. For more information, see Mediation Sequences.

The Process of message mediation is depicted in the diagram below.

In case an error occurs in the main sequence while processing, the message goes to the fault sequence.

When adding a mediator to a sequence, you can configure the mediator in design view or in source view. Usually, a mediator is configured using XML. Source view provides the XML representation of the configurations done in the UI. When you edit the source XML all changes immediately reflect in the design view as well.

Each mediator has its own XML configuration. You can change the following mediators using their source view:

  • Aggregate Mediator
  • Cache Mediator
  • Filter Mediator
  • In Mediator
  • Iterate Mediator
  • Out Mediator
  • Sequence Mediator
  • Synapse Mediator
  • Template Mediator
  • Validate Mediator

It is possible to comment out lines of code in the Synapse definition as well as in the source view of the complete EI configuration.

Mediators in a sequence can be one of the following types:

  • Node mediators - Contains child mediators.
  • Leaf mediators - Does not hold any other child mediators.

Mediators are classified as follows based on whether or not they access the message's content: 

  • Content-aware mediators: These mediators always access the message content when mediating messages (e.g., Enrich mediator).
  • Content-unaware mediators: These mediators never access the message content when mediating messages (e.g., Send mediator).
  • Conditionally content-aware mediators: These mediators could be either content-aware or content-unaware depending on their exact instance configuration. For an example a simple Log Mediator instance (i.e. configured as <log/>) is content-unaware. However a log mediator configured as <log level=”full”/> would be content-aware since it is expected to log the message payload.

Mediators are considered to be one of the main mechanisms for extending an EI. You can create custom mediators and add them to the ESB profile. This custom mediator and any other built-in mediator will be exactly the same as the API and the privileges.

The standard mediators in the ESB profile are listed in the table below. Click a link for details on that mediator. There are also many samples that demonstrate how to use mediators.

The WSO2 EI mediator catalog





CallInvoke a service in non blocking synchronous manner


Sends a message


Moves the message from the In flow to the Out flow, skipping all remaining configuration in the In flow


Inserts a reference to a sequence

RespondStops processing on the message and sends it back to the client


Drops a message

Call TemplateConstructs a sequence by passing values into a sequence template


Enriches a message


Sets or remove properties associated with the message


Logs a message



Filters a message using XPath, if-else kind of logic

ValidateValidates XML messages against a specified schema.


Filters messages using XPath, switch logic



Performs XSLT transformations on the XML payload

FastXSLTPerforms XSLT transformations on the message stream


Modifies and rewrites URLs or URL fragments

XQueryPerforms XQuery transformation


Sets or removes SOAP headers

Fault (also called Makefault)

Create SOAP Faults

PayloadFactoryTransforms or replaces message content in between the client and the back-end server
JSON Transform MediatorApplying XML to JSON transformations to individual artifacts instead of applying global synapse settings.



Evaluates messages based on whether the same message came to the ESB profile

ForEachSplits a message into a number of different messages by finding matching elements in an XPath expression of the original message.


Clones a message


Stores messages in a predefined message store


Splits a message


Combines a message


Blocks web services calls


Executes a set of mediators transactionally


Limits the number of messages


Writes data to database


Retrieves information from database

EJBCalls an external Enterprise JavaBean(EJB) and stores the result in the message payload or in a message context property.


Executes rules

BuilderBuilds the actual SOAP message, from a message, which is coming into the ESB profile through the Binary Relay. 


Evaluates user actions against a XACML policy


2-legged OAuth support

SmooksUsed to apply lightweight transformations on messages in an efficient manner.
Data MapperConverts and transforms one data format to another, or changes the structure of the data in a message. 


Creates and executes a custom mediator


Executes a mediator written in Scripting language


Creates a mediator managed by Spring

AgentPublish Event

Constructs events and publishes them to different systems such as WSO2 BAM/DAS/CEP/SP via event sinks.

  • No labels