The Love story of Integration Studio & Micro Integrator

Arunan Sugunakumar
Think Integration
Published in
7 min readSep 4, 2020

--

What is WSO2 Micro Integrator?

WSO2 Micro Integrator is an open-source Integration runtime of Enterprise Integrator which is used for integrating APIs, services, data, and SaaS, proprietary, and legacy systems. It is capable of catering services on both monolithic and microservices architecture. It is a lightweight ESB that has cloud-native capabilities.

What is WSO2 Integration Studio?

WSO2 Integration Studio is a low-code development platform in which you can develop Integration solutions that can run on the Integration runtime (Micro Integrator) of Enterprise Integrator. It provides the development environment to design, develop, debug, and test the artifacts that you create.

A low-code development platform (LCDP) is software that provides a development environment used to create application software through graphical user interfaces and configuration instead of traditional hand-coded computer programming.

WSO2 Micro Integrator and WSO2 Integration studio together create a powerful Integration framework and Low-Code development environment to develop complex Integration scenarios. In one of my previous blog, I explained what Micro Integrator is and its evolution. In another blog, I wrote a sample Integration scenario with XML like syntax which connects to an OpenWeather API and retrieves data from it. In this blog, I will be explaining the features of the WSO2 Integration studio and I will show how you can create the same Integration logic graphically in a low-code manner and run it on the embedded Micro Integrator inside the studio. We can also create a docker image of the artifacts that we create. I will also be explaining how we can write unit tests to test the solution.

I will be using Integration Studio 7.1.0 for demonstration purposes. It contains an embedded Micro Integrator 1.2.0. To download the Integration Studio, please visit https://wso2.com/integration/integration-studio/

Getting started page of WSO2 Integration Studio 7.1.0

An Integration Project is the parent project for any Project you create in the Integration Studio. Below are some of the types of projects that you would find inside an Integration Project.

  • ESB Config Project — Contains all the logic related to Integration scenario
  • Composite Exporter — Project to create the CApp or CAR resource
  • Registry Resource — Project to create resources that should be deployed in the Micro Integrator Registry
  • Connector Exporter — Project to package the WSO2 connectors that you would need to connect with 3rd party services.
  • Docker Exporter — Project to build, package, and push docker images of the Integration services.
  • Kubernetes Exporter — Project to allow you to deploy your integration solutions in a Kubernetes environment.

For our sample application, we need an Integration Project with ESB Config Project, Composite Exporter, and Docker Exporter.

Scenario: Implement a REST API that can take an array of city names and call a Weather API to collect weather-related information for each of the city and aggregate the responses so that they can be sent back as one response.

1. First, we need to create an Integration Project which consists of ESB Configs Project and a Composite Application Project.

An interesting thing to note here is that in my previous blog, we copied an XML file inside the API folder to deploy the API in the MI. Since it was an introduction blog to Micro Integrator, it was fine. But for complex developments, we can’t manage individual files. With Integration Studio, we can create a Composite Application (Simply called, CAR file or CApp file) which can consist of multiple files. It is the recommended way of deploying artifacts in Micro Integrator.

Click on New Integration Project in the Getting started page. Give a suitable project name. Make sure to select the Docker Exporter Project since we need it later.

Creating an Integration Project

2. Rather than creating the endpoint inside the API itself, I would like to create the endpoint as a separate artifact. This helps us to reuse the Endpoints in different APIs and Proxies. Also, it helps to keep the API simple.

Add the following as the URI template.

http://api.openweathermap.org/data/2.5/weather?q={uri.var.city}&appid={uri.var.appid}
Creating an Endpoint as a separate artifact

3. Next, we need to create a REST API to contain the Integration logic. Since we are going to make a POST request to our API, make sure to select the POST method in the REST API Properties.

Creating a REST API with the POST method

4. Let’s create all the mediators by doing a simple drag and drop. (If you need a clear insight on why we need to use these mediators, please refer to this blog.)

  • Property mediator
Creating a Property mediator to store the API KEY
  • Iterate mediator
Creating an Iterate mediator to iterate over the cities
  • Property mediator
Creating property mediator to store the city name
  • Send mediator
Creating a send mediator to call Weather API endpoint
  • Aggregate mediator
Creating an aggregate mediator to aggregate the response

Below is the complete Integration Solution which we created Graphically with a Low code approach.

Design view of the Weather API solution

You can switch between the Design view and the Source view and compare the source with what we did previously when we wrote the XML.

Let’s test the solution. We don’t need a separate MI runtime to test this. There is one embedded in the Studio itself.

5. Run the inbuilt Micro Integrator

Running the solution on the inbuilt Micro Integrator

6. Let’s send a POST request from the HTTP client available in the Studio.

Sending a POST request from the HTTP Client

7. Since our solution is working now, we can build a docker image with Micro Integrator 1.2.0 and this project’s composite application.

Building a docker image using the Docker Exporter

Once, the docker build is complete, you can see that the image is available in our local docker environment.

Verifying the docker image

The development of the Integration solution is now completed. Like programming, we should ensure that in the future our solution will not break due to any changes. For a complex project, we should try to write tests from the beginning itself so that we can reduce the maintainability costs in the long run.

8. Write a Unit test case to test the solution

Since we are using a third-party API, we need to create a Mock Service to mock the API since depending on a third-party service for a test-case is not recommended.

  • Name of the Mock Service: A suitable name for the mock service.
  • Mocking Endpoint Name: Endpoint name which we want to mock. (In our case it is WeatherAPIEP)
  • Mock Service Port: Port for the mock service. (Make sure that no other process is using this port)
  • Mock Service Context: Main context for the service. Should start with / (In our case, /weather)

I gave a sample response from Weather API to be sent as a response from the Mock Service.

Creating a Mock Service for Weather API

Next, we should create the Unit Test Suite.

Creating a Unit Test Suite

After creating the Unit Test suite, we need to add the Assertion details. For the expected value, I aggregated the response from the Mock Service.

Creating an Assertion inside Unit Test Suite

After creating the Assertions, we are now ready to run the Unit Test suite.

Running the Unit test suite

We have successfully created, packaged, and tested an Integration solution with the help of Integration Studio and Micro Integrator. As you can see, we never used any programming language here and it is an ideal way for anyone to develop an Integration solution on their own. Low-code or No-code development is on the rise and tech conglomerates like Amazon are also focusing on developing low-code solutions like Honeycode. It is easy to learn your way around WSO2 Integration Studio and it has enough templates in the Getting Started page to learn the platform completely. I am sure you can give a try and get amazed by the simplicity in creating an Integration solution.

Integration Studio & Micro Integrator... Still a better love story than Twilight... 

Resources

--

--

Arunan Sugunakumar
Think Integration

Software Engineer (Integration) @wso2, Graduated from University of Moratuwa (Computer Science & Eng) and GSOCer @intermineorg