Slide 1

Slide 1 text

Microservice Patterns Implemented by Eclipse MicroProfile Ivar Grimstad
 Principal Consultant, Cybercom Sweden

Slide 2

Slide 2 text

@ivar_grimstad https://github.com/ivargrimstad https://www.linkedin.com/in/ivargrimstad

Slide 3

Slide 3 text

@ivar_grimstad #microservices Introduction The Patterns Summary

Slide 4

Slide 4 text

@ivar_grimstad #JakartaEE #EE4J

Slide 5

Slide 5 text

@ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE

Slide 6

Slide 6 text

@ivar_grimstad #microservices M icroProfile 2.2 Februyary 12, 2019

Slide 7

Slide 7 text

@ivar_grimstad #microservices The Patterns

Slide 8

Slide 8 text

@ivar_grimstad #microservices 1. Microservice Architecture 2. Service per Container 3. Externalised Configuration 4. Health Check API 5. Application Metrics 6. Circuit Breaker 7. Access Token 8. Distributed Tracing

Slide 9

Slide 9 text

@ivar_grimstad #microservices

Slide 10

Slide 10 text

@ivar_grimstad #microservices Microservice Architectures #1

Slide 11

Slide 11 text

@ivar_grimstad #microservices What’s the application’s deployment architecture?

Slide 12

Slide 12 text

@ivar_grimstad #microservices Monolithic Architecture Monolithic Application

Slide 13

Slide 13 text

@ivar_grimstad #microservices Monolithic Architecture

Slide 14

Slide 14 text

@ivar_grimstad #microservices Service A Service B Service C Application Call A Call B Call C Microservice Architecture

Slide 15

Slide 15 text

@ivar_grimstad #microservices Microservice Architecture

Slide 16

Slide 16 text

@ivar_grimstad #microservices

Slide 17

Slide 17 text

@ivar_grimstad #microservices Service per Container #2

Slide 18

Slide 18 text

@ivar_grimstad #microservices How are services packaged and deployed?

Slide 19

Slide 19 text

@ivar_grimstad #microservices Application Server (Container) Service C Service B Service A Configuration A Configuration B Configuration C

Slide 20

Slide 20 text

@ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE Thin WAR

Slide 21

Slide 21 text

@ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE UberJAR

Slide 22

Slide 22 text

@ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE java -jar dukes.jar

Slide 23

Slide 23 text

@ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE Hollow JAR

Slide 24

Slide 24 text

@ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE java -jar dukes.jar dukes.war

Slide 25

Slide 25 text

@ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE Hardware Operating System JVM UberJAR Hardware Operating System JVM MicroProfile Container MicroProfile Application Hardware Operating System JVM Java EE Container Java EE Application java -jar dukes.jar java -jar dukes.jar dukes.war deployDukes.sh

Slide 26

Slide 26 text

@ivar_grimstad #microservices

Slide 27

Slide 27 text

@ivar_grimstad #microservices Hardware Operating System JVM UberJAR Hardware Operating System JVM MicroProfile Container MicroProfile Application Hardware Operating System JVM Java EE Container Java EE Application docker run dukes docker run dukes docker run dukes

Slide 28

Slide 28 text

@ivar_grimstad #microservices DEMO

Slide 29

Slide 29 text

@ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE

Slide 30

Slide 30 text

@ivar_grimstad #microservices

Slide 31

Slide 31 text

@ivar_grimstad #microservices Externalised Configuration #3

Slide 32

Slide 32 text

@ivar_grimstad #microservices How to enable a service to run in multiple environments without modification?

Slide 33

Slide 33 text

@ivar_grimstad #microservices Configuration for MicroProfile

Slide 34

Slide 34 text

@ivar_grimstad #microservices System Properties System.getProperties() Environment Variables System.getenv() Application Configuration META-INF/microprofile-config.properties

Slide 35

Slide 35 text

@ivar_grimstad #microservices DEMO

Slide 36

Slide 36 text

@ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE

Slide 37

Slide 37 text

@ivar_grimstad #microservices

Slide 38

Slide 38 text

@ivar_grimstad #microservices Health Check API #4

Slide 39

Slide 39 text

@ivar_grimstad #microservices How to detect that a running service instance is unable to handle requests?

Slide 40

Slide 40 text

@ivar_grimstad #microservices MicroProfile Health API

Slide 41

Slide 41 text

@ivar_grimstad #microservices DEMO

Slide 42

Slide 42 text

@ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE

Slide 43

Slide 43 text

@ivar_grimstad #microservices

Slide 44

Slide 44 text

@ivar_grimstad #microservices Application Metrics #5

Slide 45

Slide 45 text

@ivar_grimstad #microservices How to understand the behavior of an application and troubleshoot problems?

Slide 46

Slide 46 text

@ivar_grimstad #microservices MicroProfile Metrics

Slide 47

Slide 47 text

@ivar_grimstad #microservices DEMO

Slide 48

Slide 48 text

@ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE

Slide 49

Slide 49 text

@ivar_grimstad #microservices

Slide 50

Slide 50 text

@ivar_grimstad #microservices Circuit Breaker #6

Slide 51

Slide 51 text

@ivar_grimstad #microservices How to prevent a network or service failure from cascading to other services?

Slide 52

Slide 52 text

@ivar_grimstad #microservices

Slide 53

Slide 53 text

@ivar_grimstad #microservices

Slide 54

Slide 54 text

@ivar_grimstad #microservices DEMO

Slide 55

Slide 55 text

@ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE

Slide 56

Slide 56 text

@ivar_grimstad #microservices

Slide 57

Slide 57 text

@ivar_grimstad #microservices Access Token #7

Slide 58

Slide 58 text

@ivar_grimstad #microservices How to communicate the identity of the requestor to the services that handle the request?

Slide 59

Slide 59 text

@ivar_grimstad #microservices Basic Authentication

Slide 60

Slide 60 text

@ivar_grimstad #microservices POST /hello HTTP/1.1 Host: localhost:8080 Authorization: Basic c25vb3850nBhc3M= User-Agent: HTTPie/0.9.9 Accept: */* Content-Type: application/json Content-Length: 26 {“message”:“Hello, Duke!”}

Slide 61

Slide 61 text

@ivar_grimstad #microservices OAuth 2.0

Slide 62

Slide 62 text

@ivar_grimstad #microservices POST /hello HTTP/1.1 Host: localhost:8080 Authorization: Bearer 2YotnF2FEjrlzCsidMWpAA User-Agent: HTTPie/0.9.9 Accept: */* Content-Type: application/json Content-Length: 26 {“message”:“Hello, Duke!”} POST /hello HTTP/1.1 Host: localhost:8080 Authorization: Basic c25vb3850nBhc3M= User-Agent: HTTPie/0.9.9 Accept: */* Content-Type: application/json Content-Length: 26 {“message”:“Hello, Duke!”} POST /hello HTTP/1.1 Host: localhost:8080 Authorization: Bearer 2YotnF2FEjrlzCsidMWpAA User-Agent: HTTPie/0.9.9 Accept: */* Content-Type: application/json Content-Length: 26 {“message”:“Hello, Duke!”}

Slide 63

Slide 63 text

@ivar_grimstad #microservices JSON Web Token (JWT)

Slide 64

Slide 64 text

@ivar_grimstad #microservices POST /hello HTTP/1.1 Host: localhost:8080 Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiQ mVhcmVyIiwiYXVkIjoic2ltcGxlYXBwIiwic3ViIjoiYm9iIiwidXBuIjo iYm9iIiwiY3VzdG9tQ2xhaW0iOiJjdXN0b21WYWx1ZSIsImdyb3VwcyI6W yJhZG1pbiIsInVzZXIiXSwiaXNzIjoiaHR0cDovL29wZW5saWJlcnR5Lml vIiwiZXhwIjoxNTI1MzM5MjU5LCJpYXQiOjE1MjUyNTI4NTl9.nDDpCR2w MWsENaDGORQblErOCJ6ii1R-N6iSzVsAz2RoUlvM2PrST2qT6kje-Nz9vc ptbSpOSlF1OuJydvP8Tg3puJKI5vGyL4RMowgJHwdvv7hMZvrK1loNrPfb yv727L9UwJSZMdzL_sibiXDuj-bIBIr6yGjVF86aQnh-PWBV8HHM1iW8l1 _y351lp2CAPkfjKwLU91iIT1jO1QCwItF8Dv-zAzmhd_rOIF58eB809_5r m0MMGIuAXdgUiU2bdEJQCkTWJKNNaSu5oddZzlKaCX4hIgBdrVV6447DM0 i31YRhLpYHfbzh_NlRrRPjGPNgzOIN1RInwPC8jdg_g User-Agent: HTTPie/0.9.9 Accept: */* Content-Type: application/json Content-Length: 26 {“message”:“Hello, Duke!”}

Slide 65

Slide 65 text

@ivar_grimstad #microservices POST /hello HTTP/1.1 Host: localhost:8080 Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiQ mVhcmVyIiwiYXVkIjoic2ltcGxlYXBwIiwic3ViIjoiYm9iIiwidXBuIjo iYm9iIiwiY3VzdG9tQ2xhaW0iOiJjdXN0b21WYWx1ZSIsImdyb3VwcyI6W yJhZG1pbiIsInVzZXIiXSwiaXNzIjoiaHR0cDovL29wZW5saWJlcnR5Lml vIiwiZXhwIjoxNTI1MzM5MjU5LCJpYXQiOjE1MjUyNTI4NTl9.nDDpCR2w MWsENaDGORQblErOCJ6ii1R-N6iSzVsAz2RoUlvM2PrST2qT6kje-Nz9vc ptbSpOSlF1OuJydvP8Tg3puJKI5vGyL4RMowgJHwdvv7hMZvrK1loNrPfb yv727L9UwJSZMdzL_sibiXDuj-bIBIr6yGjVF86aQnh-PWBV8HHM1iW8l1 _y351lp2CAPkfjKwLU91iIT1jO1QCwItF8Dv-zAzmhd_rOIF58eB809_5r m0MMGIuAXdgUiU2bdEJQCkTWJKNNaSu5oddZzlKaCX4hIgBdrVV6447DM0 i31YRhLpYHfbzh_NlRrRPjGPNgzOIN1RInwPC8jdg_g User-Agent: HTTPie/0.9.9 Accept: */* Content-Type: application/json Content-Length: 26 {“message”:“Hello, Duke!”}

Slide 66

Slide 66 text

@ivar_grimstad #microservices ✦Header ✦ JSON, Base64 URL Encoded ✦ Algorithm, Type
 ✦Payload ✦ JSON, Base64 URL Encoded ✦ Standard + Custom entries
 ✦Signature ✦ Binary, Base64 URL Encoded ✦ The actual signature

Slide 67

Slide 67 text

@ivar_grimstad #microservices POST /hello HTTP/1.1 Host: localhost:8080 Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiQ mVhcmVyIiwiYXVkIjoic2ltcGxlYXBwIiwic3ViIjoiYm9iIiwidXBuIjo iYm9iIiwiY3VzdG9tQ2xhaW0iOiJjdXN0b21WYWx1ZSIsImdyb3VwcyI6W yJhZG1pbiIsInVzZXIiXSwiaXNzIjoiaHR0cDovL29wZW5saWJlcnR5Lml vIiwiZXhwIjoxNTI1MzM5MjU5LCJpYXQiOjE1MjUyNTI4NTl9.nDDpCR2w MWsENaDGORQblErOCJ6ii1R-N6iSzVsAz2RoUlvM2PrST2qT6kje-Nz9vc ptbSpOSlF1OuJydvP8Tg3puJKI5vGyL4RMowgJHwdvv7hMZvrK1loNrPfb yv727L9UwJSZMdzL_sibiXDuj-bIBIr6yGjVF86aQnh-PWBV8HHM1iW8l1 _y351lp2CAPkfjKwLU91iIT1jO1QCwItF8Dv-zAzmhd_rOIF58eB809_5r m0MMGIuAXdgUiU2bdEJQCkTWJKNNaSu5oddZzlKaCX4hIgBdrVV6447DM0 i31YRhLpYHfbzh_NlRrRPjGPNgzOIN1RInwPC8jdg_g User-Agent: HTTPie/0.9.9 Accept: */* Content-Type: application/json Content-Length: 26 {“message”:“Hello, Duke!”}

Slide 68

Slide 68 text

@ivar_grimstad #microservices { “alg”: “RS256”, “typ”: “JWT} { “token-type: “access-token”, “username”: “duke”, “scopes”: [ “java”: “everywhere” ], “exp”: 1474280963, “iat”: 1474279163 “jti”: “66881b068b249ad9” } nDDpCR2wMWsENaDGORQblErOCJ6ii1R-N6iSzVsAz2RoUlvM2PrST2qT6kje-Nz 9vcptbSpOSlF1OuJydvP8Tg3puJKI5vGyL4RMowg-JHwdvv7hMZvrK1loNrPfby v727L9UwJSZMdzL_sibiXDuj-bIBIr6yGjVF86aQnh-PWBV8HHM1iW8l1_y351l p2CAPkfjKwLU91iIT1jO1QCwItF8Dv-zAzmhd_rOIF58eB809_5rm0MMGIuAXdg UiU2bdEJQCkTWJKNNaSu5oddZzlKaCX4hIgBdrVV6447DM0i31YRhLpYHfbzh_N lRrRPjGPNgzOIN1RInwPC8jdg_g

Slide 69

Slide 69 text

@ivar_grimstad #microservices DEMO

Slide 70

Slide 70 text

@ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE Open Liberty

Slide 71

Slide 71 text

@ivar_grimstad #microservices

Slide 72

Slide 72 text

@ivar_grimstad #microservices Distributed Tracing #8

Slide 73

Slide 73 text

@ivar_grimstad #microservices How to understand the behavior of an application and troubleshoot problems?

Slide 74

Slide 74 text

@ivar_grimstad #microservices

Slide 75

Slide 75 text

@ivar_grimstad #microservices DEMO

Slide 76

Slide 76 text

@ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE Open Liberty

Slide 77

Slide 77 text

@ivar_grimstad #microservices

Slide 78

Slide 78 text

@ivar_grimstad #microservices Summary

Slide 79

Slide 79 text

@ivar_grimstad #microservices

Slide 80

Slide 80 text

@ivar_grimstad #microservices 1. Microservice Architecture 2. Service per Container 3. Externalised Configuration 4. Health Check API 5. Application Metrics 6. Circuit Breaker 7. Access Token 8. Distributed Tracing

Slide 81

Slide 81 text

@ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE

Slide 82

Slide 82 text

@ivar_grimstad #JakartaEE #EE4J

Slide 83

Slide 83 text

@ivar_grimstad #microservices

Slide 84

Slide 84 text

@ivar_grimstad #microservices Microservice Architecture http://microservices.io Samples https://github.com/ivargrimstad/microservice-patterns Microprofile http://microprofile.io Jakarta EE https://jakarta.ee

Slide 85

Slide 85 text

@ivar_grimstad #microservices cybercom.com Rem em ber to Vote!