Building Services with WSO2 Microservices Framework for Java Sanjeewa Malalgoda Technical Lead and Product Lead ( WSO2 API Manager)
Building Services with WSO2 Microservices Framework for JavaSanjeewa MalalgodaTechnical Lead and Product Lead ( WSO2 API Manager)
Agenda
o What is Microservice?o Why Microservice?o Microservices outer architecture.o WSO2 Microservice movement.o Introduction to WSO2 MSF4Jo Implementation of WSO2 MSF4Jo Develop Microservices with MSF4J(security, metrics etc. )o Demo.
What is Microservice?o Microservice architectural style is an approach to
developing a single application as a suite of small services.
o Each running in its own process and communicating with lightweight mechanisms.
o These services are built,o Around business capabilities.o Independently deployable by fully automated
deployment machinery.Ref: http://martinfowler.com/microservices/
What is Microservice?
o There is a bare minimum of centralized management of these services,o which may be written in different programming
languageso And use different data storage technologies.
Ref: http://martinfowler.com/microservices/
What is Microservice?
o Microservice is,o Small.o Running on its own process.o Communicating often via http.o Built around different business capabilities.o Written in different languages.o Use different data storage technologies.o Independently deployable by fully automated process.
What is Microservice?
o Microservice is,o Small.o Running on its own process.o Communicating often via http.o Built around different business capabilities.o Written in different languages.o Use different data storage technologies.o Independently deployable by fully automated
process.
Why Microservice?
o Problem with “big application” (a.k.a. “monolithic”)o Let say you have bigger application and you need to
scale it.
Scale, High availability
Why Microservice?
o Solutiono Split your “bigger application” into smaller granules that
can be deployed independently
Why Microservice?
o Solutiono Split your “bigger application” into smaller granules that
can be deployed independentlyo Split into Microservices
Why Microservice?
o Solutiono Scale/ Replicate each component individually. Because
each smaller service is microservice now. And they can be deploy independently.
Why Microservice?
o Replication can be restricted to those components that turn out bottleneck(we can scale) , critical(we can go for HA) without paying all components of “big application”
Why Microservice?
http://martinfowler.com/articles/microservices.html
Microservices Outer Architecture
WSO2 Microservices movementWhat do we offer as middleware platform
WSO2 Microservices movement
Introduction to WSO2 MSF4J o Lightweight & fast runtime
o Use Java annotations as a way of defining microservices APIs as well as metrics
o Support well known & widely used methods such as JAX-RS annotations
o Provide simple ways to develop & deploy microservices
o Built-in Metrics & Analytics APIs with out-of-the-box integration with WSO2 Data Analytics Server (DAS)
o 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
Implementation of WSO2 MSF4J o Based on the new WSO2 Carbon 5.0 kernelo Transport is based on Netty 4.0o Supports streamingo High performanceo 5MB pack sizeo Starts within 300mso ~25MB memory consumption for the framework
Message flow and thread model WSO2 MSF4J
Performance of WSO2 MSF4J
Advantages of WSO2 MSF4J o Quick & simple development model using simple annotationso Lightweight & high performanceo Custom interceptorso OAuth based securityo Metrics gathering & publishingo Streaming input & streaming output support
o WSO2 DevStudio based tooling for generating microservices projects starting from a Swagger API definition
o Comprehensive samples demonstrating how to develop microservices application.
Develop Microservice with WSO2 MSF4J
Developer studio support
Develop Microservice with WSO2 MSF4J
Developer studio support
Application Main Class
POM file
Microservice Implementation
Analytics and Monitoring in WSO2 MSF4J
Supports annotations
● Timed – measures execution
● Metered – measures rate of events
● Counted – counts the total invocations
● HTTPMonitored – monitors HTTP
requests
Service Matrices (Console Output & Dashboards)
Security
o Security is done via a central server issuing JWT or OAuth tokens.
o The OAuth2SecurityInterceptor verifies the token before accessing the resources.
Demo.
Demo.
Build the sample - wso2msf4j-dist-1.0.0
/samples/HelloWorld-Metrics
mvn clean install
Run the sample
java -jar helloworld-*.jar
Test the sample
curl http://localhost:8080/hello/wso2
Demo samples - https://github.com/sagara-gunathunga/msf4j-intro-webinar-samples