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

Skip to end of metadata
Go to start of metadata

Mediators provide an easy way of extending the ESB functionalities. WSO2 ESB is based on WSO2 Carbon platform which uses OSGI as the underlying technology. It implies everything that runs inside the WSO2 ESB to be OSGI bundles.

There are two ways of writing the ESB mediator:

  • Using Class Mediator - does not allow mediator specific XML configurations.
  • Writing the mediator with Factory and Serialize methods - allows mediator to have its own XML configuration.

Writing the mediator is straightforward in any of these cases. The easiest way to write the mediator is to extend your mediator class from org.apache.synapse.mediators.AbstractMediator class.

You can see the detailed information of how to write the mediator here:

1. Writing a Mediator in WSO2 ESB - Part 1                             

2. Writing a Mediator in WSO2 ESB - Part 2

After you wrote the mediator you need to build it with WSO2 ESB. You have to make your mediator an OSGI bundle in order to make it work with ESB.

Easier Way

You just need to create a regular JAR which links to the Synpase core JAR and put it into the repository/components/lib directory. The platform will automatically make it an OSGI bundle and deploy it to the server.

Harder Way

If you want to control the way of your mediator creation as an OSGI bundle, you have to write the POM files. This way you can export the packages you want, you can import packages you want etc.



It is available if your mediator uses some versioned JAR files.



Both POM files are created for the ESB 2.1 release. If you want to use them for another release, make sure you change the versions accordingly.

A POM file to create the mediator using Class Mediator.



The maven bundle plug-in was used for creating the OSGI bundle here. Make sure you export the correct package which contains the mediator code. Unless you do this, your mediator will not work.

A POM file to create the mediator with its own XML configuration using Serialize and Factory classes.

In this case, it is necessary to make the mediator an OSGI fragment of the synapse-core bundler. To achieve this, use the <Fragment-Host>synapse-core</Fragment-Host>.

Create <PROJECT_HOME>/main/resources/ and <PROJECT_HOME>/main/resources/ files with the following content as shown below, to add service provider definitions to your Maven project.

create the 2 text files

Content of the org.apache.synapse.config.xml.MediatorFactory file
Content of the org.apache.synapse.config.xml.MediatorSerializer file

After you created the mediator, drop the JAR file in to the {ESB HOME}\repository\components\dropins\ folder.

  • No labels