Introduction to MSF4J 2.0
Afkham AzeezSenior Director, Platform Architecture, WSO2,Inc.@afkham_azeez http://me.afkham.org
What is 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
• 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
interactions3
MSF4J Implementation• Based on the new Carbon 5.0 kernel
• Transport is based on Netty 4.0
• Supports streaming
• High performance
• 9MB pack size
• Starts within 300ms
• Less than 25MB memory consumption for the framework
MSF4J- Performance Comparison
MSF4J- Memory Consumption Comparison
MSF4J- Latency Comparison
MSF4J– Thread Model
Download
o MSF4J 2.0.0 release is available athttps://github.com/wso2/msf4j/releases/tag/v2.0.0o Refer to the getting started guide in GitHubo A good place to start is the samples
Core Features (1/2)• Quick & simple development model using simple
annotations
• Supports Spring annotations & runtime
• Swagger support
• ExceptionMapper
• Form processing – FormParam, FormDataParam, FormIterator
• Custom interceptors10
Core Features (2/2)• JWT based security
• Metrics gathering & publishing
• Streaming input & streaming output support
• Circuit breaker support
• WSO2 DevStudio based tooling for generating microservices projects starting from a Swagger API definition
• Comprehensive samples demonstrating how to develop microservices application
11
Getting Started• Start from Maven archetype• Start from Swagger definition
12
Start from Maven Archetypemvn archetype:generate -DarchetypeGroupId=org.wso2.msf4j \-DarchetypeArtifactId=msf4j-microservice -DarchetypeVersion=2.0.0 \-DgroupId=org.example -DartifactId=Hello-Service -Dversion=1.0.0-SNAPSHOT \-Dpackage=org.example.service -DserviceClass=HelloService
13
Start from Swagger Def
14
Runner
Spring Support• Supports standard Spring configuration annotations
such as @Configuration, @Component, @AutoWired etc. and other Spring features work with MSF4J
• Bring in other 3rd party libraries & wire them in at runtime. • e.g. Spring-JPA library to integrate the Hibernate ORM
framework with an MSF4J service
17
ExceptionMapper
18
Circuit Breaker
19
Swagger Annotations
20
Swagger Definition • http://localhost:8080/swagger• http://localhost:8080/swagger?path=/stockquote
21
Request Streaming
22
Response Streaming
23
Form Processing• @FormParam• @FormDataParam• FormParamIterator
24
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
• HTTPMonitored – monitors HTTP requests
Analytics & Monitoring
Metrics Output to Console
JMX Metrics
Analytics & Monitoring
MSF4J Pet store sample
MSF4J Pet store sample