Skip to main content

Posts

Showing posts with the label WSO2 mediator

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...