Top Banner
Building Services with WSO2 Microservices Framework for Java Sanjeewa Malalgoda Technical Lead and Product Lead ( WSO2 API Manager)
28

Building Services with WSO2 Microservices Framework for Java

Apr 16, 2017

Download

Software

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Building Services with WSO2 Microservices Framework for Java

Building Services with WSO2 Microservices Framework for JavaSanjeewa MalalgodaTechnical Lead and Product Lead ( WSO2 API Manager)

Page 2: Building Services with WSO2 Microservices Framework for Java

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.

Page 3: Building Services with WSO2 Microservices Framework for Java

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/

Page 4: Building Services with WSO2 Microservices Framework for Java

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/

Page 5: Building Services with WSO2 Microservices Framework for Java

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.

Page 6: Building Services with WSO2 Microservices Framework for Java

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.

Page 7: Building Services with WSO2 Microservices Framework for Java

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

Page 8: Building Services with WSO2 Microservices Framework for Java

Why Microservice?

o Solutiono Split your “bigger application” into smaller granules that

can be deployed independently

Page 9: Building Services with WSO2 Microservices Framework for Java

Why Microservice?

o Solutiono Split your “bigger application” into smaller granules that

can be deployed independentlyo Split into Microservices

Page 10: Building Services with WSO2 Microservices Framework for Java

Why Microservice?

o Solutiono Scale/ Replicate each component individually. Because

each smaller service is microservice now. And they can be deploy independently.

Page 11: Building Services with WSO2 Microservices Framework for Java

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”

Page 12: Building Services with WSO2 Microservices Framework for Java

Why Microservice?

http://martinfowler.com/articles/microservices.html

Page 13: Building Services with WSO2 Microservices Framework for Java

Microservices Outer Architecture

Page 14: Building Services with WSO2 Microservices Framework for Java

WSO2 Microservices movementWhat do we offer as middleware platform

Page 15: Building Services with WSO2 Microservices Framework for Java

WSO2 Microservices movement

Page 16: Building Services with WSO2 Microservices Framework for Java

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

Page 17: Building Services with WSO2 Microservices Framework for Java

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

Page 18: Building Services with WSO2 Microservices Framework for Java

Message flow and thread model WSO2 MSF4J

Page 19: Building Services with WSO2 Microservices Framework for Java

Performance of WSO2 MSF4J

Page 20: Building Services with WSO2 Microservices Framework for Java

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.

Page 21: Building Services with WSO2 Microservices Framework for Java

Develop Microservice with WSO2 MSF4J

Developer studio support

Page 22: Building Services with WSO2 Microservices Framework for Java

Develop Microservice with WSO2 MSF4J

Developer studio support

Application Main Class

POM file

Microservice Implementation

Page 23: Building Services with WSO2 Microservices Framework for Java

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

Page 24: Building Services with WSO2 Microservices Framework for Java

Service Matrices (Console Output & Dashboards)

Page 25: Building Services with WSO2 Microservices Framework for Java

Security

o Security is done via a central server issuing JWT or OAuth tokens.

o The OAuth2SecurityInterceptor verifies the token before accessing the resources.

Page 26: Building Services with WSO2 Microservices Framework for Java

Demo.

Page 27: Building Services with WSO2 Microservices Framework for Java

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

Page 28: Building Services with WSO2 Microservices Framework for Java