Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java
-
Upload
sagara-gunathunga -
Category
Software
-
view
218 -
download
0
Transcript of Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java
![Page 1: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/1.jpg)
Building Services with WSO2 Microservices Framework for Java and WSO2 Application Server
Sagara Gunathunga & Sameera Jayasoma
![Page 2: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/2.jpg)
Agenda
• Introduction to Microservices Architecture• Introduction to WSO2 MSF4J
– Hands-on Sessions• Introduction to Kubernetes/Docker• Demonstrating MSF4J deployment with Kubernetes
• Introduction to WSO2 Application Server– Hands-on Session
![Page 3: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/3.jpg)
Microservices Architecture
A method of developing software applications as a suite of independently deployable, small, modular services in which each service runs a unique process and communicates through a well-defined, lightweight mechanism to serve a business goal.
![Page 4: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/4.jpg)
Microservices
http://martinfowler.com/articles/microservices.html
![Page 5: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/5.jpg)
Inner & Outer Architecture
http://blogs.gartner.com/gary-olliffe/2015/01/30/microservices-guts-on-the-outside/
![Page 6: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/6.jpg)
WSO2 Microservices Framework for Java (MSF4J)
• Lightweight & fast runtime• Use Java annotations as a way of defining microservices APIs as well
as metrics• Support well known & widely used methods such as JAX-RS
annotations• Provide simple ways to develop & deploy microservices• Built-in Metrics & Analytics APIs with out-of-the-box integration with
WSO2 Data Analytics Server (DAS)• To be used in the WSO2 platform as a way of replacing all admin
services as well as defining other microservices for inter-component interactions
![Page 7: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/7.jpg)
MSF4J Implementation
• Based on the new WSO2 Carbon 5.0 kernel • Transport is based on Netty 4.0• Supports streaming• High performance• 5MB pack size• Starts within 300ms• ~25MB memory consumption for the framework
![Page 8: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/8.jpg)
MSF4J Performance Comparison
![Page 9: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/9.jpg)
MSF4J Memory Consumption Comparison
![Page 10: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/10.jpg)
Core Features of MSF4J
• Quick & simple development model using simple annotations• Lightweight & high performance• Custom interceptors• OAuth based security• Metrics gathering & publishing• Streaming input & streaming output support• WSO2 DevStudio based tooling for generating microservices projects
starting from a Swagger API definition• Comprehensive samples demonstrating how to develop microservices
application
![Page 11: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/11.jpg)
MSF4J Flow & Thread Model
![Page 12: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/12.jpg)
Developer Experience & Programming Model
![Page 13: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/13.jpg)
Development Model
• Maven Archetype• IDE/Build Classpath (msf4j-all.jar)• Tooling (Swagger -> Code)
![Page 14: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/14.jpg)
Maven pom.xml
![Page 15: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/15.jpg)
Maven Archetype
mvn archetype:generate-DarchetypeGroupId=org.wso2.msf4j-DarchetypeArtifactId=msf4j-microservice-DarchetypeVersion=1.0.0-DgroupId=org.example -DartifactId=myservice-Dversion=1.0.0-SNAPSHOT-Dpackage=org.example.service
![Page 16: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/16.jpg)
Example - StockQuote Microservice
![Page 17: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/17.jpg)
Application - Main Class
![Page 18: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/18.jpg)
Application - Main Class
![Page 19: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/19.jpg)
Build and Run !!!
mvn clean install
java -jar stockquote-1.0.0.jar
![Page 20: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/20.jpg)
Tooling - WSO2 Developer Studio
![Page 21: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/21.jpg)
Tooling - WSO2 Developer Studio
![Page 22: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/22.jpg)
Types of Deployment
• Standalone, Self contained jar files• OS / Container images
![Page 23: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/23.jpg)
Analytics & Monitoring
Supports annotations• Timed – measures execution • Metered – measures rate of events • Counted – counts the total invocations • HTTPMonitored – monitors HTTP requests
![Page 24: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/24.jpg)
Analytics & Monitoring
![Page 25: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/25.jpg)
Service Metrics - Console Output
![Page 26: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/26.jpg)
![Page 27: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/27.jpg)
Security
• Security is done via a central server issuing JWT or OAuth tokens.
• The OAuth2SecurityInterceptor verifies the token before accessing the resources.
![Page 28: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/28.jpg)
MSF4J Hands-on Sessions
![Page 29: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/29.jpg)
Hello World!
1.Build the sample - wso2msf4j-dist-1.0.0/samples/helloworld
mvn clean install2.Run the sample
java -jar helloworld-*.jar3.Test the sample
curl http://localhost:8080/hello/wso2
Demo samples - https://github.com/sagara-gunathunga/msf4j-intro-webinar-samples
![Page 30: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/30.jpg)
Generate a sample with Maven archetype
mvn archetype:generate -DarchetypeGroupId=org.wso2.msf4j -DarchetypeArtifactId=msf4j-microservice -DarchetypeVersion=1.0.0
![Page 31: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/31.jpg)
Production Deployment with Kubernetes and Docker
![Page 32: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/32.jpg)
The Essence of Micro-Services• Micro-Services are all about…
– Proper granularity of components – Independent deployment
• They are not a counter-proposal to SOA • They do not prove that SOA failed
– In the opposite: they require loose coupling,...• They require a methodology to determine “proper granules”
for components– Something like the holy grail of software engineering for
decades!– So, don’t expect your middleware vendors to solve this problem
for you! It’s all about YOU solving an very difficult architecture/design problem!!!
![Page 33: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/33.jpg)
The Essence of Micro-Services
• No shared DBs• Transactions• Forward Compatibility• Micro service security• Composition with other micro services• Service Discovery• Routing• Monitoring• Automation
![Page 34: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/34.jpg)
Inner & Outer Architecture
http://blogs.gartner.com/gary-olliffe/2015/01/30/microservices-guts-on-the-outside/
![Page 35: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/35.jpg)
Virtual Machines vs Containers
![Page 36: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/36.jpg)
What is Docker
• Container Virtualization• Build, pack, ship and run applications as containers• Build once, run in many places• Lightweight, Isolated
![Page 37: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/37.jpg)
Docker File System
![Page 38: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/38.jpg)
StockQuote Service Dockerfile
![Page 39: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/39.jpg)
Petstore sample
![Page 40: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/40.jpg)
Petstore sample
![Page 41: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/41.jpg)
PetStore sample
![Page 42: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/42.jpg)
Kubernetes
• Kubernetes is an open source orchestration system for Docker containers
• Docker -> Container lifecycle management
• Kubernetes -> Orchestration and container cluster management
“Kubernetes, I need 5 Tomcat and one MySQL server running at all times.”
![Page 43: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/43.jpg)
Kubernetes in a Nutshell
![Page 44: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/44.jpg)
Kubernetes Work Units• Pods - Generally represents one or more containers that
should be controlled as a single “application".
• Services - A unit that act as a basic load balancer for other containers.
• Replication Controllers - Concept of a replicated pod. Handles horizontal scaling of containers / pods. Maintain the desired number of containers.
![Page 45: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/45.jpg)
Kubernetes UI
![Page 46: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/46.jpg)
Petstore sample - deployment view
![Page 47: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/47.jpg)
Demo - Petstore
![Page 48: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/48.jpg)
Building Services with WSO2 Application Server
![Page 49: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/49.jpg)
Current status of Application Server
• Latest release - AS 5.3.0• Built on top of WSO2 Carbon• Embedded Apache Tomcat 7 and Apache TomEE 7• First class support for
– JAX-WS and JAX-RS services– JavaEE 6 Web Profile applications
![Page 50: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/50.jpg)
Future plan for Application Server
• Upcoming release - AS 6.0• NOT based on WSO2 Carbon or OSGi!• Built on top of Apache Tomcat
![Page 51: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/51.jpg)
AS 6.0
• HTTP Request Monitoring for Tomcat• Seamless integration with WSO2 Identity Server for SAML
SSO Authentication • Classloading improvements
![Page 52: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/52.jpg)
Questions?
![Page 53: Building Services with WSO2 Application Server and WSO2 Microservices Framework for Java](https://reader035.fdocuments.us/reader035/viewer/2022081517/58a133041a28abd34f8b5b5f/html5/thumbnails/53.jpg)
Thank You!
#WSO2ConEU
Share your feedback for this sessionwso2con.com/app