SlideShare a Scribd company logo
1 of 35
Download to read offline
Senior Director - Platform Architecture, WSO2
Writing Microservices Using
WSO2 MSF4J
Afkham Azeez
A lightweight,
high performance
container-native
framework for building microservices in Java
• Container-native microservices framework
• Simple way of defining microservice APIs as well as
metrics
• Provide simple ways to develop and deploy
microservices
• Built-in metrics and analytics APIs with OOB
integration with WSO2 Streaming Analytics
Vision of WSO2 MSF4J
WSO2 MSF4J - An Overview
• Simple Java-based programming model with annotations
• Fast boot up - microservices can be booted in a few
milliseconds in a Docker container and can be easily
added to a Docker image
• Secures microservices leveraging JWT, BasicAuth and
OAuth2 and has the capability to integrate with
third-party authentication servers    
• Monitors microservices service behavior with analytics
dashboards
Implementation of WSO2 MSF4J
• HTTP transport is based on Netty 4.0
• Experimental gRPC support
• Supports streaming
• High performance
• 5MB pack size
• Starts in under 300 ms
• Less than 25 MB memory consumption for the
framework
Core Features
6
Annotation-based Programming Model
• Supports JAX-RS based annotations
– Class-level annotations
– Method-level annotations
– Parameter-level annotations
– Lifecycle callback method annotations
• Supports Swagger-based annotations
– Enables generating Swagger API definition from a single
API call
– Humans and computers can discover and understand
capabilities of each service
Spring-Based Microservices
• Supports a Spring-native development model with
– Dependency Injection (DI)
– Standard configuration annotations (e.g.
@Configuration, @Component, @AutoWired)
• Makes it easy to bring in third-party libraries and wire
them in at runtime
• e.g. those familiar with Spring-JPA can use Spring-JPA
library to integrate the Hibernate ORM framework with
an WSO2 MSF4J service
Serverless Execution
• Supports server-less execution with fat JAR
– Fat JAR is a JAR file with all dependencies in one fat
(uber) JAR
– Creating a fat JAR and running it in a Java process is
referred to as serverless execution
– Serverless execution does not involve unzipping a file
and helps to start an app without a shell script
• Supports service lifecycle methods
Streaming
• Adopts efficient model to handle Streaming Input (request
messages) and Streaming Output (response messages)
• Streaming Input - HTTP chunked requests can be handled in two
ways:
– Zero-copy method – Each chunk of a request is treated separately
• chunk() method is called when requests arrive
• finished () method is called after the last chunk arrives
• error () method called if an error occurs while processing the request
– Chunk aggregation – Aggregates all chunks of the request and presents it as
a full HTTP request to the resource method
• Streaming Output – Useful when handling large data volumes – no
need to load into memory
Custom Interceptors
• Custom interceptors can be used to perform certain
actions before or after a request arrives to resource
methods
• Custom interceptors should implement the
org.wso2.msf4j.Interceptor interface
File Handling
• Serve files from the resource methods by returning either of the
following:
– java.io.File
– java.io.InputStream
– javax.ws.rs.core.Response object with a java.io.File
– java.io.InputStream entity
• Streaming is supported by default for java.io.File and
java.io.InputStream entities
• javax.ws.rs.core.StreamingOutput is also supported by WSO2
MSF4J - provides the service author more control over the chunk
size
gRPC Support
syntax = "proto3";
...
// The greeting service definition.
service HelloService {
// Sends a greeting
rpc hello (HelloRequest) returns (HelloResponse) {}
}
// The request message containing the user's name.
message HelloRequest {
string name = 1;
}
// The response message containing the greetings
message HelloResponse {
string message = 1;
}
Exception Mapper
• Supports JAX-RS ExceptionMapper, which allows the creation of
custom responses when exceptions are thrown from MSF4J services
• The following code segment shows how ExceptionMappers are
registered with the WSO2 MSF4J runtime:
JAX-RS Runtime
Exception
Mapping
Exception
Response
Thrown Exception
HTTP
Circuit Breaker
• Nygard's circuit
breaker pattern is
supported in
WSO2 MSF4J
using the Netflix
Hystrix library
Closed
On call: Pass through
Call succeeds: Reset failures count
and throw exception
Threshold reached: Trip breaker
Open
On call: Fail(throw exception)
On timeout: Attempt reset
Half-Open
On call: Pass through
Call succeeds: Reset
Call fails: Trip breaker
Trip breaker
Reset breaker
Trip
breaker
Attempt
reset
Security
• Security is done via a central server issuing JWT tokens
• The JWTSecurityInterceptor verifies the signature, expiry
and claims in the token
Analytics and Monitoring
• Supports annotations
– Timed – measures execution time
– Metered – measures rate of events
– Counted – counts the total number of invocations
– HTTPMonitored – monitors HTTP requests
Metrics Output to Console
JMX Metrics
Dashboards
Performance
2
Tooling
2
mvn archetype:generate
-DarchetypeGroupId=org.wso2.msf4j 
-DarchetypeArtifactId=msf4j-microservice
-DarchetypeVersion=2.4.2 
-DgroupId=org.example -DartifactId=Hello-Service
-Dversion=0.1-SNAPSHOT 
-Dpackage=org.example.service
-DserviceClass=HelloService
Skeleton project creation
java -jar swagger-codegen-cli.jar generate 
-i http://petstore.swagger.io/v2/swagger.json 
-l msf4j 
-o samples/server/petstore/msf4j
Generate MSF4J Code from Swagger
Use Swagger Editor
https://editor2.swagger.io
MSF4J vs Spring Boot
3
MSF4J Spring Boot (SB)
Throughput Slightly higher than SB
Latency
Similar at lower concurrencies. MSF4J displays lower latency than Spring
Boot at higher concurrencies.
Default memory
footprint
(on startup) Less than 20MB 180MB
Min memory
requirement 7MB 25MB
Distribution size 6 MB 13MB
Startup time Less than 300ms 3 sec
Built-in analytics Yes No
Built-in Swagger
support Yes No
JAXRS annotation
support Yes No
• MSF4J 2.0.0 release is available at
https://github.com/wso2/msf4j/releases/tag/v2.4.2
• Refer to the getting started guide in
http://github.com/wso2/msf4j
• A good place to start is the samples
Download and Get Started!
wso2.com

More Related Content

What's hot

Enterprise Integration with the WSO2 ESB
Enterprise Integration with the WSO2 ESB Enterprise Integration with the WSO2 ESB
Enterprise Integration with the WSO2 ESB
WSO2
 
Application development using the wso2 developer studio
Application development using the wso2 developer studioApplication development using the wso2 developer studio
Application development using the wso2 developer studio
WSO2
 
Managing ESB artifacts with the WSO2 Governance Registry
Managing ESB artifacts with the WSO2 Governance Registry Managing ESB artifacts with the WSO2 Governance Registry
Managing ESB artifacts with the WSO2 Governance Registry
WSO2
 
Building Applications with Carbon Studio on Premise and Cloud
Building Applications with Carbon Studio on Premise and CloudBuilding Applications with Carbon Studio on Premise and Cloud
Building Applications with Carbon Studio on Premise and Cloud
WSO2
 
WSO2 and 2 Degrees Case Study
WSO2 and 2 Degrees Case StudyWSO2 and 2 Degrees Case Study
WSO2 and 2 Degrees Case Study
WSO2
 
Delivering the Promise of SOA - Enterprise Integration Made Easy
Delivering the Promise of SOA - Enterprise Integration Made EasyDelivering the Promise of SOA - Enterprise Integration Made Easy
Delivering the Promise of SOA - Enterprise Integration Made Easy
WSO2
 
How the WSO2 ESB outperforms other major open source esb vendors
How the WSO2 ESB outperforms other major open source esb vendorsHow the WSO2 ESB outperforms other major open source esb vendors
How the WSO2 ESB outperforms other major open source esb vendors
WSO2
 

What's hot (20)

Enterprise Integration with the WSO2 ESB
Enterprise Integration with the WSO2 ESB Enterprise Integration with the WSO2 ESB
Enterprise Integration with the WSO2 ESB
 
Application development using the wso2 developer studio
Application development using the wso2 developer studioApplication development using the wso2 developer studio
Application development using the wso2 developer studio
 
Managing ESB artifacts with the WSO2 Governance Registry
Managing ESB artifacts with the WSO2 Governance Registry Managing ESB artifacts with the WSO2 Governance Registry
Managing ESB artifacts with the WSO2 Governance Registry
 
Building Applications with Carbon Studio on Premise and Cloud
Building Applications with Carbon Studio on Premise and CloudBuilding Applications with Carbon Studio on Premise and Cloud
Building Applications with Carbon Studio on Premise and Cloud
 
WSO2 and 2 Degrees Case Study
WSO2 and 2 Degrees Case StudyWSO2 and 2 Degrees Case Study
WSO2 and 2 Degrees Case Study
 
Microservices Technology Stack
Microservices Technology StackMicroservices Technology Stack
Microservices Technology Stack
 
Delivering the Promise of SOA - Enterprise Integration Made Easy
Delivering the Promise of SOA - Enterprise Integration Made EasyDelivering the Promise of SOA - Enterprise Integration Made Easy
Delivering the Promise of SOA - Enterprise Integration Made Easy
 
Debugging Microservices - key challenges and techniques - Microservices Odesa...
Debugging Microservices - key challenges and techniques - Microservices Odesa...Debugging Microservices - key challenges and techniques - Microservices Odesa...
Debugging Microservices - key challenges and techniques - Microservices Odesa...
 
Asynchronous Microservices in nodejs
Asynchronous Microservices in nodejsAsynchronous Microservices in nodejs
Asynchronous Microservices in nodejs
 
Microservices Architecture
Microservices ArchitectureMicroservices Architecture
Microservices Architecture
 
How the WSO2 ESB outperforms other major open source esb vendors
How the WSO2 ESB outperforms other major open source esb vendorsHow the WSO2 ESB outperforms other major open source esb vendors
How the WSO2 ESB outperforms other major open source esb vendors
 
Quarterly WSO2 Platform Update Webinar - Q1 2016
Quarterly WSO2 Platform Update Webinar - Q1 2016Quarterly WSO2 Platform Update Webinar - Q1 2016
Quarterly WSO2 Platform Update Webinar - Q1 2016
 
Introduction to WSO2 Integration Platform
Introduction to WSO2 Integration PlatformIntroduction to WSO2 Integration Platform
Introduction to WSO2 Integration Platform
 
WSO2-ESB - The backbone of Enterprise Integration
WSO2-ESB - The backbone of Enterprise IntegrationWSO2-ESB - The backbone of Enterprise Integration
WSO2-ESB - The backbone of Enterprise Integration
 
Integration Microservices
Integration MicroservicesIntegration Microservices
Integration Microservices
 
Micro-services architecture
Micro-services architectureMicro-services architecture
Micro-services architecture
 
Deep-dive into WSO2 ESB 5.0
Deep-dive into WSO2 ESB 5.0 Deep-dive into WSO2 ESB 5.0
Deep-dive into WSO2 ESB 5.0
 
WSO2 ESB - The Backbone of Integration
WSO2 ESB - The Backbone of Integration WSO2 ESB - The Backbone of Integration
WSO2 ESB - The Backbone of Integration
 
Accelerate DevOps/Microservices and Kubernetes
Accelerate DevOps/Microservices and KubernetesAccelerate DevOps/Microservices and Kubernetes
Accelerate DevOps/Microservices and Kubernetes
 
Microservices for Enterprises
Microservices for Enterprises Microservices for Enterprises
Microservices for Enterprises
 

Viewers also liked

Viewers also liked (20)

[WSO2Con EU 2017] The Win-Win-Win of Water Authority HHNK
[WSO2Con EU 2017] The Win-Win-Win of Water Authority HHNK[WSO2Con EU 2017] The Win-Win-Win of Water Authority HHNK
[WSO2Con EU 2017] The Win-Win-Win of Water Authority HHNK
 
[WSO2Con EU 2017] Introduction to Ballerina
[WSO2Con EU 2017] Introduction to Ballerina[WSO2Con EU 2017] Introduction to Ballerina
[WSO2Con EU 2017] Introduction to Ballerina
 
[WSO2Con EU 2017] How to Learn and Contribute to Ballerina
[WSO2Con EU 2017] How to Learn and Contribute to Ballerina[WSO2Con EU 2017] How to Learn and Contribute to Ballerina
[WSO2Con EU 2017] How to Learn and Contribute to Ballerina
 
[WSO2Con EU 2017] Transforming the Way We Deliver Operational Technology
[WSO2Con EU 2017] Transforming the Way We Deliver Operational Technology[WSO2Con EU 2017] Transforming the Way We Deliver Operational Technology
[WSO2Con EU 2017] Transforming the Way We Deliver Operational Technology
 
[WSO2Con EU 2017] From the Trenches: IoT Customer Stories
[WSO2Con EU 2017] From the Trenches: IoT Customer Stories[WSO2Con EU 2017] From the Trenches: IoT Customer Stories
[WSO2Con EU 2017] From the Trenches: IoT Customer Stories
 
[WSO2Con EU 2017] Integration Platform Strategy for Digital Transformation
[WSO2Con EU 2017] Integration Platform Strategy for Digital Transformation[WSO2Con EU 2017] Integration Platform Strategy for Digital Transformation
[WSO2Con EU 2017] Integration Platform Strategy for Digital Transformation
 
[WSO2Con EU 2017] Building Smarter Cities: Examples from Deployments Across t...
[WSO2Con EU 2017] Building Smarter Cities: Examples from Deployments Across t...[WSO2Con EU 2017] Building Smarter Cities: Examples from Deployments Across t...
[WSO2Con EU 2017] Building Smarter Cities: Examples from Deployments Across t...
 
[WSO2Con EU 2017] Travis Perkins - Our Digital Transformation & the Importanc...
[WSO2Con EU 2017] Travis Perkins - Our Digital Transformation & the Importanc...[WSO2Con EU 2017] Travis Perkins - Our Digital Transformation & the Importanc...
[WSO2Con EU 2017] Travis Perkins - Our Digital Transformation & the Importanc...
 
[WSO2Con EU 2017] How API Management at Suva is Helping in Reducing Costs to ...
[WSO2Con EU 2017] How API Management at Suva is Helping in Reducing Costs to ...[WSO2Con EU 2017] How API Management at Suva is Helping in Reducing Costs to ...
[WSO2Con EU 2017] How API Management at Suva is Helping in Reducing Costs to ...
 
[WSO2Con EU 2017] WHO CARES? A WSO2 Cloud Oriented Reference Architecture for...
[WSO2Con EU 2017] WHO CARES? A WSO2 Cloud Oriented Reference Architecture for...[WSO2Con EU 2017] WHO CARES? A WSO2 Cloud Oriented Reference Architecture for...
[WSO2Con EU 2017] WHO CARES? A WSO2 Cloud Oriented Reference Architecture for...
 
[WSO2Con EU 2017] Implementing Data Exchange Infrastructure in Government
[WSO2Con EU 2017] Implementing Data Exchange Infrastructure in Government[WSO2Con EU 2017] Implementing Data Exchange Infrastructure in Government
[WSO2Con EU 2017] Implementing Data Exchange Infrastructure in Government
 
[WSO2Con EU 2017] Fraud Prevention and Compliance in Financial Sector with WS...
[WSO2Con EU 2017] Fraud Prevention and Compliance in Financial Sector with WS...[WSO2Con EU 2017] Fraud Prevention and Compliance in Financial Sector with WS...
[WSO2Con EU 2017] Fraud Prevention and Compliance in Financial Sector with WS...
 
[WSO2Con EU 2017] WSO2 Unleashed: Full Stack Automation, Pitfalls and Solutions
[WSO2Con EU 2017] WSO2 Unleashed: Full Stack Automation, Pitfalls and Solutions[WSO2Con EU 2017] WSO2 Unleashed: Full Stack Automation, Pitfalls and Solutions
[WSO2Con EU 2017] WSO2 Unleashed: Full Stack Automation, Pitfalls and Solutions
 
[WSO2Con EU 2017] Keynote: Digital Transformation in the Guise of a Regulatio...
[WSO2Con EU 2017] Keynote: Digital Transformation in the Guise of a Regulatio...[WSO2Con EU 2017] Keynote: Digital Transformation in the Guise of a Regulatio...
[WSO2Con EU 2017] Keynote: Digital Transformation in the Guise of a Regulatio...
 
[WSO2Con EU 2017] Keynote: Mobile Identity in the Digital Economy
[WSO2Con EU 2017] Keynote: Mobile Identity in the Digital Economy[WSO2Con EU 2017] Keynote: Mobile Identity in the Digital Economy
[WSO2Con EU 2017] Keynote: Mobile Identity in the Digital Economy
 
[WSO2Con EU 2017] Building Smart, Connected Products with WSO2 IoT Platform
[WSO2Con EU 2017] Building Smart, Connected Products with WSO2 IoT Platform[WSO2Con EU 2017] Building Smart, Connected Products with WSO2 IoT Platform
[WSO2Con EU 2017] Building Smart, Connected Products with WSO2 IoT Platform
 
[WSO2Con EU 2017] Streaming Analytics Patterns for Your Digital Enterprise
[WSO2Con EU 2017] Streaming Analytics Patterns for Your Digital Enterprise[WSO2Con EU 2017] Streaming Analytics Patterns for Your Digital Enterprise
[WSO2Con EU 2017] Streaming Analytics Patterns for Your Digital Enterprise
 
[WSO2Con EU 2017] Turning a Product Company into a Cloud Company
[WSO2Con EU 2017] Turning a Product Company into a Cloud Company[WSO2Con EU 2017] Turning a Product Company into a Cloud Company
[WSO2Con EU 2017] Turning a Product Company into a Cloud Company
 
[WSO2Con EU 2017] Crafting an API Strategy with an API Marketplace
[WSO2Con EU 2017] Crafting an API Strategy with an API Marketplace[WSO2Con EU 2017] Crafting an API Strategy with an API Marketplace
[WSO2Con EU 2017] Crafting an API Strategy with an API Marketplace
 
2017 09-07-ray-wijewardene
2017 09-07-ray-wijewardene2017 09-07-ray-wijewardene
2017 09-07-ray-wijewardene
 

Similar to [WSO2Con EU 2017] Writing Microservices Using MSF4J

Performance of Microservice Frameworks on different JVMs
Performance of Microservice Frameworks on different JVMsPerformance of Microservice Frameworks on different JVMs
Performance of Microservice Frameworks on different JVMs
Maarten Smeets
 
Better Enterprise Integration With the WSO2 ESB 4.5.1
Better Enterprise Integration With the WSO2 ESB 4.5.1Better Enterprise Integration With the WSO2 ESB 4.5.1
Better Enterprise Integration With the WSO2 ESB 4.5.1
WSO2
 
Event Bus as Backbone for Decoupled Microservice Choreography (JFall 2017)
Event Bus as Backbone for Decoupled Microservice Choreography (JFall 2017)Event Bus as Backbone for Decoupled Microservice Choreography (JFall 2017)
Event Bus as Backbone for Decoupled Microservice Choreography (JFall 2017)
Lucas Jellema
 

Similar to [WSO2Con EU 2017] Writing Microservices Using MSF4J (20)

WSO2 Microservices Framework for Java - Product Overview
WSO2 Microservices Framework for Java - Product OverviewWSO2 Microservices Framework for Java - Product Overview
WSO2 Microservices Framework for Java - Product Overview
 
Introduction to WSO2 Microservices Framework for Java - MSF4J - WSO2Con Asia ...
Introduction to WSO2 Microservices Framework for Java - MSF4J - WSO2Con Asia ...Introduction to WSO2 Microservices Framework for Java - MSF4J - WSO2Con Asia ...
Introduction to WSO2 Microservices Framework for Java - MSF4J - WSO2Con Asia ...
 
Building Services with WSO2 Microservices framework for Java and WSO2 AS
Building Services with WSO2 Microservices framework for Java and WSO2 ASBuilding Services with WSO2 Microservices framework for Java and WSO2 AS
Building Services with WSO2 Microservices framework for Java and WSO2 AS
 
Oracle WebLogic Diagnostics & Perfomance tuning
Oracle WebLogic Diagnostics & Perfomance tuningOracle WebLogic Diagnostics & Perfomance tuning
Oracle WebLogic Diagnostics & Perfomance tuning
 
Building Services with WSO2 Application Server and WSO2 Microservices Framewo...
Building Services with WSO2 Application Server and WSO2 Microservices Framewo...Building Services with WSO2 Application Server and WSO2 Microservices Framewo...
Building Services with WSO2 Application Server and WSO2 Microservices Framewo...
 
WSO2Con 2015-us-introduction-to-mss-v2
WSO2Con 2015-us-introduction-to-mss-v2WSO2Con 2015-us-introduction-to-mss-v2
WSO2Con 2015-us-introduction-to-mss-v2
 
Performance of Microservice Frameworks on different JVMs
Performance of Microservice Frameworks on different JVMsPerformance of Microservice Frameworks on different JVMs
Performance of Microservice Frameworks on different JVMs
 
An Introduction to WSO2 Microservices Framework for Java
An Introduction to WSO2 Microservices Framework for JavaAn Introduction to WSO2 Microservices Framework for Java
An Introduction to WSO2 Microservices Framework for Java
 
WSO2 Workshop Sydney 2016 - Microservices
WSO2 Workshop Sydney 2016 - MicroservicesWSO2 Workshop Sydney 2016 - Microservices
WSO2 Workshop Sydney 2016 - Microservices
 
An Introduction to WSO2 Microservices Framework for Java
An Introduction to WSO2 Microservices Framework for JavaAn Introduction to WSO2 Microservices Framework for Java
An Introduction to WSO2 Microservices Framework for Java
 
Developing Micro-Services for Cloud using Java
Developing Micro-Services for Cloud using JavaDeveloping Micro-Services for Cloud using Java
Developing Micro-Services for Cloud using Java
 
Event Bus as Backbone for Decoupled Microservice Choreography (Oracle Code, A...
Event Bus as Backbone for Decoupled Microservice Choreography (Oracle Code, A...Event Bus as Backbone for Decoupled Microservice Choreography (Oracle Code, A...
Event Bus as Backbone for Decoupled Microservice Choreography (Oracle Code, A...
 
WebLogic Stability; Detect and Analyse Stuck Threads
WebLogic Stability; Detect and Analyse Stuck ThreadsWebLogic Stability; Detect and Analyse Stuck Threads
WebLogic Stability; Detect and Analyse Stuck Threads
 
Introduction to WSO2 Microservices Framework for Java (MSF4J) 2.0
Introduction to WSO2 Microservices Framework for Java (MSF4J) 2.0Introduction to WSO2 Microservices Framework for Java (MSF4J) 2.0
Introduction to WSO2 Microservices Framework for Java (MSF4J) 2.0
 
SC'16 PMIx BoF Presentation
SC'16 PMIx BoF PresentationSC'16 PMIx BoF Presentation
SC'16 PMIx BoF Presentation
 
The Oracle Application Container Cloud as the Microservices Platform (APAC OU...
The Oracle Application Container Cloud as the Microservices Platform (APAC OU...The Oracle Application Container Cloud as the Microservices Platform (APAC OU...
The Oracle Application Container Cloud as the Microservices Platform (APAC OU...
 
Better Enterprise Integration With the WSO2 ESB 4.5.1
Better Enterprise Integration With the WSO2 ESB 4.5.1Better Enterprise Integration With the WSO2 ESB 4.5.1
Better Enterprise Integration With the WSO2 ESB 4.5.1
 
Collector Web Services
Collector Web ServicesCollector Web Services
Collector Web Services
 
Event Bus as Backbone for Decoupled Microservice Choreography (JFall 2017)
Event Bus as Backbone for Decoupled Microservice Choreography (JFall 2017)Event Bus as Backbone for Decoupled Microservice Choreography (JFall 2017)
Event Bus as Backbone for Decoupled Microservice Choreography (JFall 2017)
 
NodeJS - Server Side JS
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS
 

More from WSO2

More from WSO2 (20)

Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
 
WSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AI
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
WSO2CON 2024 - Elevating the Integration Game to the Cloud
WSO2CON 2024 - Elevating the Integration Game to the CloudWSO2CON 2024 - Elevating the Integration Game to the Cloud
WSO2CON 2024 - Elevating the Integration Game to the Cloud
 
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & InnovationWSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
 
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and ApplicationsWSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
WSO2CON 2024 - Software Engineering for Digital Businesses
WSO2CON 2024 - Software Engineering for Digital BusinessesWSO2CON 2024 - Software Engineering for Digital Businesses
WSO2CON 2024 - Software Engineering for Digital Businesses
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
 
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 

[WSO2Con EU 2017] Writing Microservices Using MSF4J

  • 1. Senior Director - Platform Architecture, WSO2 Writing Microservices Using WSO2 MSF4J Afkham Azeez
  • 3. • Container-native microservices framework • Simple way of defining microservice APIs as well as metrics • Provide simple ways to develop and deploy microservices • Built-in metrics and analytics APIs with OOB integration with WSO2 Streaming Analytics Vision of WSO2 MSF4J
  • 4. WSO2 MSF4J - An Overview • Simple Java-based programming model with annotations • Fast boot up - microservices can be booted in a few milliseconds in a Docker container and can be easily added to a Docker image • Secures microservices leveraging JWT, BasicAuth and OAuth2 and has the capability to integrate with third-party authentication servers     • Monitors microservices service behavior with analytics dashboards
  • 5. Implementation of WSO2 MSF4J • HTTP transport is based on Netty 4.0 • Experimental gRPC support • Supports streaming • High performance • 5MB pack size • Starts in under 300 ms • Less than 25 MB memory consumption for the framework
  • 7. Annotation-based Programming Model • Supports JAX-RS based annotations – Class-level annotations – Method-level annotations – Parameter-level annotations – Lifecycle callback method annotations • Supports Swagger-based annotations – Enables generating Swagger API definition from a single API call – Humans and computers can discover and understand capabilities of each service
  • 8. Spring-Based Microservices • Supports a Spring-native development model with – Dependency Injection (DI) – Standard configuration annotations (e.g. @Configuration, @Component, @AutoWired) • Makes it easy to bring in third-party libraries and wire them in at runtime • e.g. those familiar with Spring-JPA can use Spring-JPA library to integrate the Hibernate ORM framework with an WSO2 MSF4J service
  • 9. Serverless Execution • Supports server-less execution with fat JAR – Fat JAR is a JAR file with all dependencies in one fat (uber) JAR – Creating a fat JAR and running it in a Java process is referred to as serverless execution – Serverless execution does not involve unzipping a file and helps to start an app without a shell script • Supports service lifecycle methods
  • 10. Streaming • Adopts efficient model to handle Streaming Input (request messages) and Streaming Output (response messages) • Streaming Input - HTTP chunked requests can be handled in two ways: – Zero-copy method – Each chunk of a request is treated separately • chunk() method is called when requests arrive • finished () method is called after the last chunk arrives • error () method called if an error occurs while processing the request – Chunk aggregation – Aggregates all chunks of the request and presents it as a full HTTP request to the resource method • Streaming Output – Useful when handling large data volumes – no need to load into memory
  • 11. Custom Interceptors • Custom interceptors can be used to perform certain actions before or after a request arrives to resource methods • Custom interceptors should implement the org.wso2.msf4j.Interceptor interface
  • 12. File Handling • Serve files from the resource methods by returning either of the following: – java.io.File – java.io.InputStream – javax.ws.rs.core.Response object with a java.io.File – java.io.InputStream entity • Streaming is supported by default for java.io.File and java.io.InputStream entities • javax.ws.rs.core.StreamingOutput is also supported by WSO2 MSF4J - provides the service author more control over the chunk size
  • 13. gRPC Support syntax = "proto3"; ... // The greeting service definition. service HelloService { // Sends a greeting rpc hello (HelloRequest) returns (HelloResponse) {} } // The request message containing the user's name. message HelloRequest { string name = 1; } // The response message containing the greetings message HelloResponse { string message = 1; }
  • 14. Exception Mapper • Supports JAX-RS ExceptionMapper, which allows the creation of custom responses when exceptions are thrown from MSF4J services • The following code segment shows how ExceptionMappers are registered with the WSO2 MSF4J runtime: JAX-RS Runtime Exception Mapping Exception Response Thrown Exception HTTP
  • 15. Circuit Breaker • Nygard's circuit breaker pattern is supported in WSO2 MSF4J using the Netflix Hystrix library Closed On call: Pass through Call succeeds: Reset failures count and throw exception Threshold reached: Trip breaker Open On call: Fail(throw exception) On timeout: Attempt reset Half-Open On call: Pass through Call succeeds: Reset Call fails: Trip breaker Trip breaker Reset breaker Trip breaker Attempt reset
  • 16. Security • Security is done via a central server issuing JWT tokens • The JWTSecurityInterceptor verifies the signature, expiry and claims in the token
  • 17. Analytics and Monitoring • Supports annotations – Timed – measures execution time – Metered – measures rate of events – Counted – counts the total number of invocations – HTTPMonitored – monitors HTTP requests
  • 18. Metrics Output to Console
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 29. mvn archetype:generate -DarchetypeGroupId=org.wso2.msf4j -DarchetypeArtifactId=msf4j-microservice -DarchetypeVersion=2.4.2 -DgroupId=org.example -DartifactId=Hello-Service -Dversion=0.1-SNAPSHOT -Dpackage=org.example.service -DserviceClass=HelloService Skeleton project creation
  • 30. java -jar swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l msf4j -o samples/server/petstore/msf4j Generate MSF4J Code from Swagger
  • 32. MSF4J vs Spring Boot 3
  • 33. MSF4J Spring Boot (SB) Throughput Slightly higher than SB Latency Similar at lower concurrencies. MSF4J displays lower latency than Spring Boot at higher concurrencies. Default memory footprint (on startup) Less than 20MB 180MB Min memory requirement 7MB 25MB Distribution size 6 MB 13MB Startup time Less than 300ms 3 sec Built-in analytics Yes No Built-in Swagger support Yes No JAXRS annotation support Yes No
  • 34. • MSF4J 2.0.0 release is available at https://github.com/wso2/msf4j/releases/tag/v2.4.2 • Refer to the getting started guide in http://github.com/wso2/msf4j • A good place to start is the samples Download and Get Started!