Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Write a Custom Mediator in WSO2 ESB

DZone's Guide to

How to Write a Custom Mediator in WSO2 ESB

Free Resource

Modernize your application architectures with microservices and APIs with best practices from this free virtual summit series. Brought to you in partnership with CA Technologies.

I will use WSO2 Developer Studio to write the custom mediator.

Click Developer studio tab and click open dashboard.








You can write the mediator logic in the following. 
Next create a carbon application project.

Next give the project name and select necessary dependencies.



Give a project name and click finish.

Next click "create archive"

Select the location (in file system) , Click 'OK'

Place the mediator (.car) to wso2esb-4.0.3/repository/deployment/server/carbonapps

The following code is a sample proxy service which will use a custom mediator
<proxy xmlns="http://ws.apache.org/ns/synapse" name="test" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <class name="org.wso2.carbon.sample.FirstMediator" />
         <log level="full" />
         <send>
            <endpoint>
               <address uri="http://localhost:8282/services/SimpleStockQuoteService/" />
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <send />
      </outSequence>
   </target>
</proxy>



The Integration Zone is proudly sponsored by CA Technologies. Learn from expert microservices and API presentations at the Modernizing Application Architectures Virtual Summit Series.

Topics:

Published at DZone with permission of Achala Chathuranga Aponso, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}