Skip to main content

Posts

Showing posts from 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

How to enable wire log in WSO2 ESB

The passthrough HTTP transport is the main transport, which handles HTTP/HTTPS messages in WSO2 ESB.  Un-comment the following entry in the  <ESB_HOME/repository/conf/log4j.properties  file to enable wire logs for the passthrough HTTP transport:  log4j.logger.org.apache.synapse.transport.http.wire=DEBUG Then restart the server

Sending an email using WSO2 Gmail Connector

The Gmail connector allows you to access the Gmail REST API through WSO2 ESB  and send an Email . Gmail  is a free, Web-based e-mail service provided by Google.  First download the Gmail Connector from  WSO2 store . And Start the WSO2 ESB server using below steps. download the ESB runtime ZIP file , and then extract the ZIP file. The path to this folder will be referred to as  <ESB_HOME>  throughout the post. Navigate to the  <PRODUCT_HOME>/bin/  directory using the Command Prompt. To start the server in a typical environment: On Windows:   wso2server.bat --run On Linux/Mac OS:   sh wso2server.sh To start the server in the background mode of Linux:  sh wso2server.sh start To stop the server running in this mode, you will enter:  sh wso2server.sh stop now go to https://localhost:9443/carbon and log into the management console using  username admin and password admin Step 1 :  Now go to  Home -> Manage -> Connectors -> Add.  Upl

When To Use Indexes In MySQL

When deciding when and how to create an index in your MySQL database, it's important to consider how the data is being used. Let's say you have a database of  students . We will create it like this: CREATE TABLE `students` ( `id` int ( 11 ) NOT NULL AUTO_INCREMENT , `first_name` varchar ( 255 ) DEFAULT NULL , `last_name` varchar ( 255 ) DEFAULT NULL , `class` varchar ( 255 ) DEFAULT NULL , PRIMARY KEY ( `id` ) ) ENGINE = InnoDB Indexes are best used on columns that are frequently used in where clauses, and in any kind of sorting, such as "order by". You should also pay attention to whether or not this information will change frequently, because it will slow down your updates and inserts. Since you wont frequently be adding students, you don't have to worry about the inserts Let's say that you will be looking up the students with a web interface and the end user will be typing in the students name to find them, since r