an introduction to wso2 microservices framework for java

25
Introduction to WSO2 Microservices Framework for Java Sagara Gunathunga Software Architect WSO2 [email protected] | @sagaras

Upload: wso2-inc

Post on 15-Apr-2017

1.116 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: An Introduction to WSO2 Microservices Framework for Java

Introduction to WSO2 Microservices Framework for Java

Sagara Gunathunga

Software Architect WSO2

[email protected] | @sagaras

Page 2: An Introduction to WSO2 Microservices Framework for Java

•  Test •  Test

2

Page 3: An Introduction to WSO2 Microservices Framework for Java

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

Page 4: An Introduction to WSO2 Microservices Framework for Java

4

What is WSO2 MSF4J?

A lightweight, high performance framework for building Microservices in Java

Page 5: An Introduction to WSO2 Microservices Framework for 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

Page 6: An Introduction to WSO2 Microservices Framework for Java

MSF4J-PerformanceComparison

Page 7: An Introduction to WSO2 Microservices Framework for Java

MSF4J-MemoryConsump7onComparison

Page 8: An Introduction to WSO2 Microservices Framework for Java

MSF4JImplementa7on•  TransportisbasedonNe/y4.0

•  Supportsstreaming

•  Highperformance

•  Lowmemoryfootprint

•  Startswithin300ms

Page 9: An Introduction to WSO2 Microservices Framework for Java

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 samples o  https://github.com/wso2/msf4j/tree/v1.0.0/samples

Page 10: An Introduction to WSO2 Microservices Framework for Java

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

Page 11: An Introduction to WSO2 Microservices Framework for Java

Security •  Security is done via a central server issuing JWT tokens

•  The JWTSecurityInterceptor verifies the signature, expiry & claims in the token

Page 12: An Introduction to WSO2 Microservices Framework for Java

Analytics & Monitoring

•  Supports annotations •  Timed – measures execution time •  Metered – measures rate of events •  Counted – Counts the total invocations

Page 13: An Introduction to WSO2 Microservices Framework for Java

Analytics & Monitoring

Page 14: An Introduction to WSO2 Microservices Framework for Java

Analytics & Monitoring

Page 15: An Introduction to WSO2 Microservices Framework for Java

Tooling (Swagger -> Code)

Swagger API Definition

MSS Code

1

2

3

Page 16: An Introduction to WSO2 Microservices Framework for Java

MSF4J in Action!

https://github.com/sagara-gunathunga/msf4j-intro-webinar-samples

Page 17: An Introduction to WSO2 Microservices Framework for Java

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

Page 18: An Introduction to WSO2 Microservices Framework for Java

1. Helloworld MSF4J

@Path("/hello") public class HelloWorld { @GET @Path("/{user}") public String hello(@PathParam("user") String user) { return "Hello " + user; } }

Page 19: An Introduction to WSO2 Microservices Framework for Java

1. Helloworld MSF4J

public class Application { public static void main(String[] args) { new MicroservicesRunner() .deploy(new HelloWorld()) .start(); } }

Page 20: An Introduction to WSO2 Microservices Framework for Java

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){ …........................................... ............................................... } }

Page 21: An Introduction to WSO2 Microservices Framework for Java

2. MSF4J Interceptors

public class Application { public static void main(String[] args) { new MicroservicesRunner() .deploy(new HelloWorld()) .addInterceptor(new BasicAuthInterceptor ()) .start(); } }

Page 22: An Introduction to WSO2 Microservices Framework for Java

3. MSF4J Metrics

@Path("/hello") public class HelloWorld { @GET @Path("/{user}") @Metered public String hello(@PathParam("user") String user) { return "Hello " + user; } }

Page 23: An Introduction to WSO2 Microservices Framework for Java

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(); } }

Page 24: An Introduction to WSO2 Microservices Framework for Java

4. MSF4J JPA Sample

Database

Hibernatepersistence

JPA API

User DAO

User Resource

Page 25: An Introduction to WSO2 Microservices Framework for Java

CONTACT US !