An Introduction to WSO2 Microservices Framework for Java
-
Upload
sagara-gunathunga -
Category
Software
-
view
256 -
download
0
Transcript of An Introduction to WSO2 Microservices Framework for Java
Introduction to WSO2 Microservices Framework for Java
Sagara Gunathunga
Software ArchitectWSO2
[email protected] | @sagaras
• Test• Test
2
Previous webinars
• http://wso2.com/library/webinars/2016/01/a-pragmatic-approach-to-microservice-architecture-the-role-of-middleware/
• http://wso2.com/library/webinars/2016/02/deep-dive-into-microservice-inner-architecture/
• http://wso2.com/library/webinars/2016/02/deep-dive-into-microservice-outer-architecture/
3
4
What is WSO2 MSF4J?
A lightweight, high performance framework for building Microservices in Java
Vision for 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 subset of JAX-RS & JSR 250 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)
• Built-in security with out of the box integration with WSO2 IS
MSF4J- Performance Comparison
MSF4J- Memory Consumption Comparison
MSF4J Implementation• Transport is based on Netty 4.0
• Supports streaming
• High performance
• Low memory footprint
• Starts within 300ms
Download
o MSS 1.0.0 release is available at https://github.com/wso2/msf4j/releases/tag/v1.0.0
o Refer to the getting started guide in GitHub
o A good place to start is the sampleso https://github.com/wso2/msf4j/tree/v1.0.0/samples
Core Features• Quick & simple development model using simple annotations
• Interceptor API for message interception
• JWT based security context propagation• • Metrics gathering & publishing – Console, JMX, WSO2 DAS
• WSO2 DevStudio based tooling for generating microservices projects starting from a Swagger API definition
• Comprehensive samples demonstrating how to develop Microservices application
• Kubernetes and Docker based reference archeterure and reference application
Security• Security is done via a central server issuing JWT tokens
• The JWTSecurityInterceptor verifies the signature, expiry & claims in the token
Analytics & Monitoring
• Supports annotations• Timed – measures execution time• Metered – measures rate of events• Counted – Counts the total invocations
Analytics & Monitoring
Analytics & Monitoring
Tooling (Swagger -> Code)
Swagger API Definition
MSS Code
1
2
3
MSF4J in Action!
https://github.com/sagara-gunathunga/msf4j-intro-webinar-samples
1. Helloworld MSF4J
mvn archetype:generate -Dfilter=org.wso2.msf4j:msf4j-microservice
OR
mvn archetype:generate -DarchetypeGroupId=org.wso2.msf4j \-DarchetypeArtifactId=msf4j-microservice -DarchetypeVersion=1.0.0 \-DgroupId=org.wso2.webinar.samples.msf4j -DartifactId=Hello -Dversion=1.0.0-SNAPSHOT \-Dpackage=org.wso2.webinar.samples.msf4j -DserviceClass=Hello
1. Helloworld MSF4J
@Path("/hello")public class HelloWorld {
@GET @Path("/{user}") public String hello(@PathParam("user") String user) {
return "Hello " + user;
}
}
1. Helloworld MSF4J
public class Application {
public static void main(String[] args) {
new MicroservicesRunner() .deploy(new HelloWorld()) .start();
}}
2. MSF4J Interceptors
public class BasicAuthInterceptor implements Interceptor {
@Override public boolean preCall(HttpRequest request, HttpResponder responder, ServiceMethodInfo serviceMethodInfo){ …........................................... ............................................... }
@Override public void postCall(HttpRequest request, HttpResponseStatus status, ServiceMethodInfo serviceMethodInfo){ …........................................... ............................................... }}
2. MSF4J Interceptors
public class Application {
public static void main(String[] args) {
new MicroservicesRunner() .deploy(new HelloWorld()) .addInterceptor(new BasicAuthInterceptor ()) .start();
}}
3. MSF4J Metrics
@Path("/hello")public class HelloWorld {
@GET @Path("/{user}") @Metered public String hello(@PathParam("user") String user) {
return "Hello " + user;
}
}
3. MSF4J Metrics
public class Application {
public static void main(String[] args) {
new MicroservicesRunner() .deploy(new HelloWorld()) .addInterceptor(new MetricsInterceptor().init(MetricReporter.CONSOLE, MetricReporter.JMX)) .start();
}}
4. MSF4J JPA Sample
Database
Hibernate persistence
JPA API
User DAO
User Resource