Overview of the tutorial
In this article, we will discuss how the lightweight container called webMethods Microservices Runtime helps us to host microservices you develop in Software AG Designer and use those microservices inside API Gateway for grouping services and exposing them as a single service.
Use case explanation
An online travel service portal in our example MakeMyTrip (Internally developed service using Software AG Designer and exposed as HTTP resource API) offers us providing the list of Airline Service Providers such as AirAsia, IndiGo, Vistara & SpiceJet which helps us to travel based on convenient Airfare Guarantee and so on. In this example, will build such an Airline service using Designer and expose it as an HTTP resource API. Once the services are ready, we can deploy the services inside Microservice Docker Container and use those lightweight service retrieving the flight information. In this case, we use the API Gateway capabilities called API mashups which helps us grouping multiple services and exposing them as a single API.
Prerequisites
You should have Docker installed in your environment and it is running as a daemon.
You should have webMethods Microservices Runtime installed in your docker host environment.
You should have webMethods API Gateway installed.
You should unzip and copy the given IS packages (AirAsia.zip, IndiGo.zip, SpiceJet.zip, Vistara.zip) to the location < installDir >/IntegrationServer/packages/.
Required knowledge
A basic understanding of developing services and generating HTTP resource API using Software AG Designer.
A basic understanding of API Gateway.
Building Docker images
If your webMethods Microservices Runtime is installed under /opt/softwareag directory, the following steps can be used to generate a Docker image containing custom packages.
Generate base Dockerfile for webMethods Microservices Runtime using the following command.
Note: Docker file will get created inside installDir with the filename “Dockerfile_IS”.
Execute the below command to build the Docker File to create a Docker image.
Execute the below command to view docker Image.
Execute the below command to create the Docker File for a custom package using the base image.
Note: Docker file for custom package will get created under “<installDir> /IntegrationServer/packages/" with the file name airasia_IS_Pkg, indigo_IS_Pkg, spicejet_IS_Pkg, vistara_IS_Pkg.
Execute the below command to build the docker image for custom package.
Execute the below command to view the docker Image created using a custom package.
Execute the below command to run the docker image.
Execute the below command to verify whether containers are up and running.
After the successful execution of steps above, you can connect to the running container from Browser on the primary port that is mapped to port 5551 so on and check whether the package deployed on each Microservice containers exist under package explorer.
After the successful deploy of service, our next goal is to call the services which are running inside multiple MSR Docker containers and use those microservices inside API Gateway for grouping services and exposing them as a single service.
To create an API Mashups in API Gateway please go through the link. In this tutorial, we are importing an already exported archive of API Mashup that is MakeMyTrip.zip in API Gateway. The selected archive will install all other required APIs along with it such as AirAsia, IndiGo, SpiceJet, Vistara.
Update the Straight Through Routing for all the APIs such as AirAsia, IndiGo, SpiceJet, Vistara
http://$ {DockerHost}:5551/rad/AirAsia.APIs:AirAsiaSpec/${sys:resource_path}
http://$ {DockerHost}:5552/rad/IndiGo.APIs:IndiGoSpec/${sys:resource_path}
http://$ {DockerHost}:5553/rad/Spicejet.APIs:SpicejetSpec/${sys:resource_path}
http://$ {DockerHost}:5554/rad/Vistara.APIs:VistaraSpec/${sys:resource_path}
Note: The service deployed to MSR Docker containers required three Resource parameters such as to, from and depart which are of type String.
example: from: BLR, to: BOM, depart: DD/MM/YYYY.
While configuring API Mashups, the query parameters to, from, depart added as Resource parameters; which are of type Query-string as shown below.
API Mashup contains the below flow.
In this flow, we connect four invoke steps in parallel with two aggregators. For this, we need four invoke steps and two aggregators.
Connect: Start → Aggregator → Invoke step1 again Aggregator → Invoke step 2 again Aggregator → Invoke step3 again Aggregator → Invoke step 4 → Aggregator → End.
Each service added to the Invoke step takes input as Incoming headers and Query parameter as shown below.
Note: This step should be followed for each service added to the Invoke step.
In this tutorial, we are going to use API Portal as a client application to invoke the APIs. To know about API Portal go the link. Currently, Activate and publish only MakeMyTrip API to the API Portal.
After publishing, we can see the API is listed under API Gallery, which is ready for the consumers to tryout the API. To Invoke an API we need to pass required parameters such as to, from and depart and also the header Accept: application/json.
After the successful invocation of the API, we receive the Response Data with flight details as given below.
Disclaimer
The information provided by SoftwareAG in the article "API Gateway and Microservice Runtime Integration" is for general informational and educational purposes only and is not a substitute for professional advice. All the entity names such as MakeMyTrip, AirAsia, IndiGo, Vistara, SpiceJet, etc. are just indicative and have no business relations.
#API-Gateway#webMethods#Integration-Server-and-ESB#Integration-Server#microservice#wiki#microservice-container