LIGHT

  • News
  • Docs
  • Community
  • Reddit
  • GitHub

What's on this Page

  • Setting up the Environment
    • Utilizing IntelliJ IDEA
    • Utilizing Command Line
  • Execution
  • Explore Further
  • Attempt Other Handlers

Quick Start - Microservices Chain Application

This is the Quick Start tutorial that utilizes the pre-built repository to provide an introduction to MS Chain Services. If you prefer to do a step-by-step setup of MS Chain Services please visit the MS Chain Services Home

You will need the following dependencies before starting this tutorial:

  • Java JDK 11 (I prefer OpenJDK but Oracle JDK will do)
  • Maven
  • Git
  • Docker

This quick start tutorial is designed for anyone beginning to utilize Light-4j and wants to gain a general understanding of how to setup a microservice chain application utilizing four APIs. This example found in light-example-4j/rest/swagger/ms_chain shows four APIs being utilized as such:

API A -> API B, API B -> API C, API C -> API D

Setting up the Environment

You are able to utlized two methods in order to build the pom.xml. One method shown below is how to run all four APIs within IntelliJ IDEA through the application solely. In order to gain a deeper look into this demonstration, it is recommended to attempt it through the command line.

Utilizing IntelliJ IDEA

After cloning the above git repository, the ms_chain directory must be opened and in order to correctly run Maven, we must go into the directory containing the pom.xml file (/rest/swagger/ms_chain/api_a/httpschain) and option click>*“Add as Maven Project”*. This will create a **classpath of module** which should be selected in IntelliJ’s *“Edit Configurations”*.

Once we have our environment set up, we can begin to test it and see if API A will call the other three APIs.

Utilizing Command Line

In order to run the Microservices Chain Pattern we must finally execute all APIs (A, B, C, and D) onto their ports. The example sets up the ports 7441, 7442, 7443, and 7444, respectively. Within the separate API folder directories (E.g. api_a/httpschain) run the Maven command to run the API on the port:

mvn install exec:exec

If you do not specify where your pom.xml file is, we must run the maven command from the directory it is in. In this example it is in api_a/httpschain. Also note that our api_a/generated does not include the chain services code, but is simply the “blueprint” of our APIs.

Execution

Regardless of the platform you used to build the pom.xml after the completion of many tests, the output for running API A should be :

Http Server started on ip:0.0.0.0 Port:7441
Https Server started on ip:0.0.0.0 Port:7441

Run this three more times for APIs B, C, and D. Do not forget to ”Add As Maven Project“ for the remaining APIs if you are utilizing IntelliJ and utilizing "mvn install exec:exec" in separate terminal windows if using the command line. The output, excluding port numbers, should be the same.

If you come across an error when initializing a port, visit your server.yml file in each directory (A, B, C, and D) and change the *Httpsport” number to a unique port currently not in use OR ensure the port is not already in use. Note: each API must have a separate port number.

Once this is completed separately for all four APIs, you can begin execution and testing. Open a new shell and execute the following command.

curl -k https://localhost:7441/v1/data
What is curl? Curl simply sends a request. In the command line, the curl command is entered with the option -k as it allows curl to proceed and operate even for server connections otherwise considered insecure. Furthermore, we input port 7441 for API A. Our /v1/data is our GET Handler from our PathHandlerProvider.java.

The output following this is:

["API D: Message 1","API D: Message 2","API C: Message 1","API C: Message 2","API B: Message 1","API B: Message 2","API A: Message 1","API A: Message 2"]%

Which if we study our DataGetHandler.java (Just from API A) we can see the final output seems to be a returned list of appended strings:

API_A FILE

list.add("API A: Message 1");
list.add("API A: Message 2");

The remaining 3 API files also append their strings, and the final output returns the list.

Explore Further

In order to understand the differences between these four entities, explore the PathHandlerProvider.java in the respective directories (api_x/httpschain). API A holds more connection establishment calls and checks than API D.

Attempt Other Handlers

Other handlers can be found in PathHandlerProvider.java and utilized in the same way as our initial curl for example:

curl -k https://localhost:7441/v1/health

and will output:

Ok%

 

Conclusion

In this tutorial, a Microservice Chain Pattern application was implemented locally with general understanding of the difference between our generated directory and our httpschain directory, and their differing uses. It is also recommended to strengthen your understanding by creating your own system using Light-4j

Return to our Tutorials page to explore more.

  • About Light
    • Overview
    • Testimonials
    • What is Light
    • Features
    • Principles
    • Benefits
    • Roadmap
    • Community
    • Articles
    • Videos
    • License
    • Why Light Platform
  • Getting Started
    • Get Started Overview
    • Environment
    • Light Codegen Tool
    • Light Rest 4j
    • Light Tram 4j
    • Light Graphql 4j
    • Light Hybrid 4j
    • Light Eventuate 4j
    • Light Oauth2
    • Light Portal Service
    • Light Proxy Server
    • Light Router Server
    • Light Config Server
    • Light Saga 4j
    • Light Session 4j
    • Webserver
    • Websocket
    • Spring Boot Servlet
  • Architecture
    • Architecture Overview
    • API Category
    • API Gateway
    • Architecture Patterns
    • CQRS
    • Eco System
    • Event Sourcing
    • Fail Fast vs Fail Slow
    • Integration Patterns
    • JavaEE declining
    • Key Distribution
    • Microservices Architecture
    • Microservices Monitoring
    • Microservices Security
    • Microservices Traceability
    • Modular Monolith
    • Platform Ecosystem
    • Plugin Architecture
    • Scalability and Performance
    • Serverless
    • Service Collaboration
    • Service Mesh
    • SOA
    • Spring is bloated
    • Stages of API Adoption
    • Transaction Management
    • Microservices Cross-cutting Concerns Options
    • Service Mesh Plus
    • Service Discovery
  • Design
    • Design Overview
    • Design First vs Code First
    • Desgin Pattern
    • Service Evolution
    • Consumer Contract and Consumer Driven Contract
    • Handling Partial Failure
    • Idempotency
    • Server Life Cycle
    • Environment Segregation
    • Database
    • Decomposition Patterns
    • Http2
    • Test Driven
    • Multi-Tenancy
    • Why check token expiration
    • WebServices to Microservices
  • Cross-Cutting Concerns
    • Concerns Overview
  • API Styles
    • Light-4j for absolute performance
    • Style Overview
    • Distributed session on IMDG
    • Hybrid Serverless Modularized Monolithic
    • Kafka - Event Sourcing and CQRS
    • REST - Representational state transfer
    • Web Server with Light
    • Websocket with Light
    • Spring Boot Integration
    • Single Page Application
    • GraphQL - A query language for your API
    • Light IBM MQ
    • Light AWS Lambda
    • Chaos Monkey
  • Infrastructure Services
    • Service Overview
    • Light Proxy
    • Light Mesh
    • Light Router
    • Light Portal
    • Messaging Infrastructure
    • Centralized Logging
    • COVID-19
    • Light OAuth2
    • Metrics and Alerts
    • Config Server
    • Tokenization
    • Light Controller
  • Tool Chain
    • Tool Chain Overview
  • Utility Library
  • Service Consumer
    • Service Consumer
  • Development
    • Development Overview
  • Deployment
    • Deployment Overview
    • Frontend Backend
    • Linux Service
    • Windows Service
    • Install Eventuate on Windows
    • Secure API
    • Client vs light-router
    • Memory Limit
    • Deploy to Kubernetes
  • Benchmark
    • Benchmark Overview
  • Tutorial
    • Tutorial Overview
  • Troubleshooting
    • Troubleshoot
  • FAQ
    • FAQ Overview
  • Milestones
  • Contribute
    • Contribute to Light
    • Development
    • Documentation
    • Example
    • Tutorial
“Quick Start - Microservices Chain Application” was last updated: July 5, 2021: fixes #275 checked and corrected grammar/spelling for majority of pages (#276) (b3bbb7b)
Improve this page
  • News
  • Docs
  • Community
  • Reddit
  • GitHub
  • About Light
  • Getting Started
  • Architecture
  • Design
  • Cross-Cutting Concerns
  • API Styles
  • Infrastructure Services
  • Tool Chain
  • Utility Library
  • Service Consumer
  • Development
  • Deployment
  • Benchmark
  • Tutorial
  • Troubleshooting
  • FAQ
  • Milestones
  • Contribute