Skip to main content

Posts

Showing posts from September, 2018

Example of WSO2 Spring mediator

The  Spring Mediator  exposes a spring bean as a mediator. The Spring Mediator creates an instance of a mediator, which is managed by Spring. This Spring bean must implement the  Mediator  interface for it to act as a Mediator. Syntax of Spring Mediator <spring:spring bean="exampleBean" key="string"/> First, we need to create a Mediator Project for Bean classes. (for more information visit the  How to use WSO2 Class Mediator in WSO2 ESB  ) For explaining clearly, I have created to Person and Student Beans. Person Bean. package lk.harshana; import org.apache.synapse.MessageContext; import org.apache.synapse.mediators.AbstractMediator; public class Person extends AbstractMediator { private String name; private String address; private String email; @Override public boolean mediate(MessageContext arg0) { System.out.println("starting person"); System.out.println("name : " + name); System.out.println("address : &

Aggregate multiple JSON responses with WSO2 Aggregate mediator

We have 2 APIs which are passing JSON responses as follows {     "name": "Harshana",     "address": "Warakapola",     "vehicleNo": "BGP 3417" } { "name": "madusanka", "address": "colombo", "vehicleNo": "BEG 8765" } Now we need to pass the response by aggregating these responses as a single response. {     "response1": {         "hAddress": "colombo",         "name": "madusanka",         "vehicle": "BEG 8765"     },     "response2": {         "hAddress": "Warakapola",         "name": "Harshana",         "vehicle": "BGP 3417"     } } Okay, We can do this by using the WSO2 Aggregrate mediator in WSO2 ESB. The Aggregate mediator implements the Message Aggregator enterprise integration pattern and aggregates the re

How to use WSO2 Class Mediator in WSO2 ESB

The  Class Mediator  creates an instance of a custom-specified class and sets it as a mediator. If any properties are specified, the corresponding setter methods are invoked once on the class during initialization. Use the Class mediator for user-specific, custom developments only when there is no built-in mediator that already provides the required functionality.  The syntax of Class Mediator in ESB < class   name= "class-name" >     <property name= "string"   value= "literal" >     </property> </ class > Creating a Class Mediator lets use the Eclipse  WSO2 Developer Studio Create a New  Mediator project by selecting File --> New --> project --> Mediator Project Now you have class mediator by extending the AbstractMediator class. Then you need to implement the mediate methods Sample class mediator implementation is as follows. package lk.harshana; import org.apache.synapse.Mess