All docs This doc
||
Skip to end of metadata
Go to start of metadata

The Micro Integrator profile (MI profile) of WSO2 Enterprise Integrator (WSO2 EI) is designed in a highly container-friendly manner, and thereby, it is ideal for you to use it for Microservices Architecture (MSA)-based solutions, which are deployed in container-based environments. 

Let’s try a simple scenario with respect to a health care service using the Micro Integrator profile, where a patient makes an inquiry specifying the doctor's specialization (category) to retrieve a list of doctors that match the specialization. The required information is available in a backend microservice deployed in the MSF4J profile of WSO2 Enterprise Integrator (WSO2 EI). 

We configure an API resource in the Micro Integrator profile of WSO2 EI that receives the client request, instead of the client sending messages directly to the back-end service, thereby decoupling the client and the back-end service. 


In this tutorial, you create a REST API in the Micro Integrator profile to connect to a REST back-end service (microservice) that is defined as an HTTP endpoint in the Micro Integrator profile. If you want to see how information stored in a database (instead of a microservice) can be used, see the tutorial on sending a simple message to a datasource.


Before you begin,

  • Download the product installer from here, and run the installer.
    Let's call the installation location of your product the <EI_HOME> directory.

    Note that if you used the product installer to install your product, the <EI_HOME> is located in a place specific to your OS as shown below:

    OSHome directory
    Mac OS/Library/WSO2/EnterpriseIntegrator/6.3.0
    WindowsC:\Program Files\WSO2\EnterpriseIntegrator\6.3.0\
    Ubuntu/usr/lib/wso2/EnterpriseIntegrator/6.3.0
    CentOS/usr/lib64/EnterpriseIntegrator/6.3.0
  • Select and download the relevant WSO2 EI tooling ZIP file based on your operating system, and then extract it. The path to this folder is referred to as <EI_TOOLING> throughout this tutorial.

    For information on any error message you get, see the troubleshooting tips given under Installing Enterprise Integrator Tooling.

  • Download the MSF4J service, and copy the JAR file to the <EI_HOME>/wso2/msf4j/deployment/microservices folder. The back-end service is now deployed in the MSF4J profile of WSO2 EI.


Let's get started!

This tutorial includes the following sections:

Downloading the message mediation artifacts

Requests going through the Micro Integrator profile of WSO2 EI are called messages. You can configure the message mediation process in the Micro Integrator profile that routes all received messages to the back-end service (healthcare service). We use the Eclipse-based WSO2 EI Tooling to create the message mediation artifacts and then deploy them to the Micro Integrator profile of WSO2 EI.

See the following topics for a description of the concepts that you need to know when creating the required artifacts:

Download the pre-packaged Composite Application, which includes all the message mediation artifacts that are required to send a request through the Micro integrator profile to the back-end service. These artifacts are created using the Eclipse-based WSO2 EI Tooling. For information on creating these artifacts, see Creating the deployable artifacts project.

Deploying the artifacts

Add the CAR file you downloaded to the <EI_HOME>/wso2/microIntegrator/repository/deployment/server/carbonapps directory to deploy it in the Micro Integrator profile.

Note

  • In a CAR file, if a particular artifact name is different from the relevant artifact file name, re-deploying the CAR file fails with an error.
  • If a CAR file has one or more artifacts that are named differently from the relevant artifact file name, you are unable to remove those artifacts from memory when you delete the CAR file.

Starting the Micro Integrator profile

Follow the steps given below to start the Micro Integrator profile.

Open a terminal and execute the following command:

wso2ei-6.3.0-micro-integrator

Go to Start Menu -> Programs -> WSO2 -> Enterprise Integrator 6.3.0 Micro Integrator. This will open a terminal and start the Micro Integrator profile.

The C-App will be successfully deployed when the server starts.

Starting the MSF4J profile

To be able to send requests to the back-end service (which is an MSF4J service deployed in MSF4J profile), you need to first start the MSF4J profile:

Open a terminal and execute the following command:

wso2ei-6.3.0-msf4j

Go to Start Menu -> Programs -> WSO2 -> Enterprise Integrator 6.3.0 MSF4J. This will open a terminal and start the MSF4J profile.

The Healthcare service is now active and you can start sending requests to the service.

Sending requests to the Micro Integrator profile

Let's send a request to our REST API (HealthcareAPI), which is now deployed in the Micro Integrator profile of WSO2 EI. You will need a REST client like curl for this.

  1. Open a command line terminal and enter the following request:

    curl -v http://localhost:8290/healthcare/querydoctor/surgery 

    The above request is formed as per the URI-Template defined when creating the endpoint.

    http://<host>:<port>/healthcare/{uri.var.category}

    The {uri.var.category} of the above URI is derived from the URI-Template defined when creating the API resource.

    http://<host>:<port>/querydoctor/{category}

    Other categories you can try sending in the request are:

    • cardiology

    • gynaecology

    • ent

    • paediatric

  2. You will see the response message from the HealthcareService with a list of available doctors and the relevant details.

    [{"name":"thomas collins",
      "hospital":"grand oak community hospital",
      "category":"surgery",
      "availability":"9.00 a.m - 11.00 a.m",
      "fee":7000.0},
     {"name":"anne clement",
      "hospital":"clemency medical center",
      "category":"surgery",
      "availability":"8.00 a.m - 10.00 a.m",
      "fee":12000.0},
     {"name":"seth mears",
      "hospital":"pine valley community hospital",
      "category":"surgery",
      "availability":"3.00 p.m - 5.00 p.m",
      "fee":8000.0}
  3. Now, check the Micro Integrator profile's server console in Eclipse, and you will see the following message: 
    INFO - LogMediator message = "Welcome to HealthcareService"

    This is the message printed by the Log mediator when the message from the client is received in the In sequence of the API resource.

You have now created and deployed an API resource in the Micro Integrator profile, which receives requests, logs a message using the Log mediator, sends the request to a back-end service using the Send mediator, and returns a response to the requesting client. 

  • No labels