#WISSENTEILEN
#WISSENTEILEN
Arne Limburg | Enterprise Architect | open knowledge GmbH
@_openKnowledge | @ArneLimburg
Microservices
mit dem Microprofile
#WISSENTEILEN
ÜBER OPEN KNOWLEDGE
Branchenneutrale Softwareentwicklung & IT-Beratung
#WISSENTEILEN
ÜBER MICH
• Enterprise Architect bei der open knowledge GmbH
• Themen
• Microservices
• Domain Driven Design
• APIs
• Architektur
• Coaching
• Technologie (Java EE / Jakarta EE / Microprofile)
Arne Limburg
#WISSENTEILEN
Mein Freund der Microservice
#WISSENTEILEN
#WISSENTEILEN
Das geht
mit JEE?
#WISSENTEILEN
Technologisch?
Auf jeden Fall!
#WISSENTEILEN
Management Monitoring Availability Security
(* Java EE 7 APIs)
#WISSENTEILEN
Ok, das geht mit JEE.
Aber passt das auch?
#WISSENTEILEN
„Max cohesion, min coupling“
• JEE Business Component
• Boundary Entity Control Pattern
• je Service ein eigenes WAR
• Kommunikation via REST
#WISSENTEILEN
#WISSENTEILEN
Unabhängig?
#WISSENTEILEN
JEE
#WISSENTEILEN
App Server?
#WISSENTEILEN
#WISSENTEILEN
Ich will meinen
Monolithen
zurück!
#WISSENTEILEN
Don‘t panic!
#WISSENTEILEN
Folks, we must talk …
#WISSENTEILEN
#WISSENTEILEN
„Just enough Server“
• Self-Contained Java Microservices (.jar)
• Java EE Komponenten on demand
• Embedded Servlet / Web Engine
• more to come …
Das geht mit Java EE?
JEE
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
„An open forum to optimize Enterprise Java
for a microservices architecture by innovating
across multiple implementations and
collaborating on common areas of interest
with a goal of standardization.“
Die Mission
#WISSENTEILEN
Brücke zwischen Community und Standard
• breite Kooperation von Herstellern
• Portabel zwischen Implementierungen
• Förderung von Experimentierfreudigkeit
• Risikominimierung
• zügige Innovationen
Die Idee
#WISSENTEILEN
Der Weg in die MicroProfile Zukunft:
• Schritt 1: Den „Hebel“ Java EE nutzen
• Schritt 2: Organische Innovationen
• Schritt 3: Zusammenarbeit via Open Source
Die Umsetzung
(*aktuelle Planung: 2-4 Releases/Jahr)
#WISSENTEILEN
Q4
2016
Move to
(*MicroProfile 1.0: JAX-RS 2.0, CDI 1.2, JSON-P 1.0)
Q3
2019
MP
v. 3.0
Q4
2019
MP
v. 2.2
Q2
2017
MP
v. 1.1
Q1
2019
MP
v. 3.1/3.2
#WISSENTEILEN
#WISSENTEILEN
Hello World
#WISSENTEILEN
Hello World
#WISSENTEILEN
I am so NOT impressed!
#WISSENTEILEN
Get ready
for more …
#WISSENTEILEN
Distributed
Configuration
#WISSENTEILEN
Wie kann ich auf einheitliche Art und Weise
in meinen Services unterschiedlichste
Konfigurationsmechanismen nutzen?
• MicroProfile Config 1.3
Distributed Configuration
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
MicroProfile Config 1.3
• Default ConfigSources*
System Properties, Env Vars & Config File
• Custom ConfigSources*
z.B. DB oder ConfigServer
• Startup vs. Laufzeit
ConfigProperty vs Provider
Distributed Configuration
*inkl. ordinal
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
Configuration
#WISSENTEILEN
Up & Running?
#WISSENTEILEN
Wie kann ich auf einheitliche Art und Weise
den Health Status und weitere Metriken
meines Microservices abfragen?
• MicroProfile HealthCheck 2.1
• MicroProfile Metrics 2.2
Up & Running
#WISSENTEILEN
MicroProfile HealthCheck 2.1
• M2M, e.g Kuberentes Liveness & Readiness
• terminate, shutdown, replace?
• Single HC Endpoint pro MP Runtime (/health)
• logisches UND (gesund, wenn alle gesund)
• REST/HTTP (andere optional z.B. JMX)
Up & Running
#WISSENTEILEN
Health check for @Readiness of connection pool
#WISSENTEILEN
*optional secured
http://myhost.com:8080/health/[live|ready]*
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
MicroProfile Metrics 2.2
• deutlich mehr als nur UP/DOWN Info für
Scopes „base“, „vendor“, „application“
• Datentrends für Kapazitätsplanung
• Auslastung für automatisches Scalling
• proaktives Feststellen von Problemen*
Up & Running
(* z.B. Disk-Usage Anomalie)
#WISSENTEILEN
MicroProfile Metrics 2.2
• Pflicht- und Optional-Metrics
• Tags via Metric Description & Config API
• Metadaten (unit, type, description, …)
• Reusable Metrics (default ist false)
• JSON & Prometheus Format (mehr geplant)
Up & Running
#WISSENTEILEN
#WISSENTEILEN
https://myhost.com:9443/metrics/application/...
*A server SHOULD implement TLS encryption by default.
#WISSENTEILEN
MicroProfile Metrics 2.2
• @ Timer
• @ Counter
• @ Gauge
• @ Meter
• @ Histogram
Up & Running
#WISSENTEILEN
Up & Running?
#WISSENTEILEN
Resilience
#WISSENTEILEN
Wie kann ich mein System so aufbauen,
dass es auch bei temporäre Ausfällen und
Problemsituation einzelner Microservices
stabil läuft (a.k.a. Resilient)?
• MicroProfile Fault Tolerance 2.0
Resilience
#WISSENTEILEN
MicroProfile Fault Tolerance 2.0
• Business Logik um Fehlertoleranz erweitern
• Trennung der Logik von deren Ausführung
• Ausführung erlaubt Resilience Patterns
• CDI Interceptor als Mittel zum Zweck
• Hystrix/Failsafe als Vorbilder für Standard API
Resilience
#WISSENTEILEN
MicroProfile Fault Tolerance 2.0
• @Timeout
• @ Retry
• @ Fallback
• @ CircuitBreaker
• @ Bulkhead
Resilience
(Konfiguration via Config API möglich)
#WISSENTEILEN
Fault Tolerance via @Retry
#WISSENTEILEN
Fault Tolerance via @Timeout und @Fallback
#WISSENTEILEN
Circuit
Breaker
#WISSENTEILEN
Circuit
Breaker
#WISSENTEILEN
Circuit
Breaker
#WISSENTEILEN
Fault Tolerance via @CircuitBreaker und @Fallback
#WISSENTEILEN
Bulkheads
#WISSENTEILEN
Bulkheads
#WISSENTEILEN
Bulkheads
#WISSENTEILEN
Fault Tolerance via @Bulkhead und @Fallback
#WISSENTEILEN
Resilience
#WISSENTEILEN
Typesafe
REST Client
#WISSENTEILEN
Typesafe Client
#WISSENTEILEN
Security
#WISSENTEILEN
Wie sichere ich meine Microservices gegen
unbefugten Zugriff ab OHNE dass bei jedem
Service eine neue Authentifizierung und
Authorisierung stattfinden muss?
• MicroProfile JWT Auth 1.1
Security
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
MicroProfile JWT Auth 1.1
• Security Token aus Request extrahieren
• Validierung des Tokens vornehmen
• Claims aus Token extrahieren
• (JEE) Security Context erzeugen
Security
#WISSENTEILEN
MicroProfile JWT Auth 1.1
• type, alg, kid (header)
• iss, sub, exp, iat, jti, (payload IANA*)
• upn, groups (payload mp jwt auth)
• etliche optionale Claims
Security
(*Internet Assigend Number Authority)
#WISSENTEILEN
JWT Auth Step 1: MS als „requires MP-JWT“ markieren
#WISSENTEILEN
JWT Auth Step 2: Token / Claims injecten
#WISSENTEILEN
JWT Auth Step 3: Role-based Access Control hinzufügen
#WISSENTEILEN
Security
#WISSENTEILEN
Distributed
Tracing
#WISSENTEILEN
Wie lässt sich ein Request-Flow über
Servicegrenzen hinaus verfolgen?
• MicroProfile Open Tracing 1.3
Tracing
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
MicroProfile Open Tracing 1.3
• verteiltes Tracing über Servicegrenzen hinweg
• Correlation ID als gemeinsamer Nenner
• OpenTracing Standard als Basis*
• Achtung: KEIN eigener Tracing Service
sondern lediglich dessen Support
Tracing *https://opentracing.io
#WISSENTEILEN
Tracing für JAX-RS Methoden aktivieren
#WISSENTEILEN
Tracing für einzelne Methoden deaktivieren
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
Tracing
#WISSENTEILEN
API
Description
#WISSENTEILEN
Wie kann ich meine Microservices APIs
so dokumentieren, dass sie von anderen
verstanden und genutzt werden können.
• MicroProfile Open API 1.1
API Description
#WISSENTEILEN
#WISSENTEILEN
MicroProfile Open API 1.1
• OpenAPI v3 Standard (abgeleitet von Swagger)
• Scan- und Annotationen-basiert (fast 50 @s)
• frei konfigurierbar (Scanpath etc.)
• mit YAML, JSON kombinierbar (in META-INF)
• Filter setzen via Config API
API Description
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
API Description
#WISSENTEILEN
What comes
next?
#WISSENTEILEN
#WISSENTEILEN
MicroProfile
Configuration
Fault Tolerance
Health Check
Metrics
JWT Token Security
Disributed Tracing
OpenAPI
CDI 2.0
JSON-P 1.1
JAX-RS 2.1
JSON-B 1.0
Distributed Logging
Distributes TX / LRA
Service Discovery
Bean Validation
…
#WISSENTEILEN
MicroProfile
WebSockets
Concurrency Utilities
Reactive Messaging
Async/Reactive
EJB Lite
Servlets
HTTP/2
Uber-jar
Eventing Systems
Big Data/NoSQL
NetFlix OSS Integration
jCache
Java 9 Modularity
...
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
„Komplexität
wird durch Microservices
verlagert, nicht verringert!
by Lars Röwekamp
#WISSENTEILEN
#WISSENTEILEN
#WISSENTEILEN
? ? ?
@ArneLimburg
@_openknowledge
#WISSENTEILEN
Getting started ...
.
MicroProfile.io
bit.ly/MicroProfileForum
github.com/microprofile/microprofile-samples
#WISSENTEILEN
KONTAKT
ARNE LIMBURG
ENTERPRISE ARCHITECT
arne.limburg@openknowledge.de
+49 (0)441 4082 – 0
@ArneLimburg
@_openknowledge
OFFENKUNDIGGUT
#WISSENTEILEN
BILDNACHWEISE
#01 FabrikaSimf – shutterstock.com
#06, #17 © Andrew Rich – istockphoto.com
#15 © Chris Munns – Amazon – CC Attribution License
#30, #41, #55, #70, #72, #87, #97, #106 © print10 – istockphoto.com
#112 ©MichaelJayBerlin - shutterstock.com
All other pictures inside this presentation orginate
from pixabay.com or were created by my own.

Microservices mit dem MicroProfile