Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Microservice Patterns - Implemented by Eclipse MicroProfile

Microservice Patterns - Implemented by Eclipse MicroProfile

Eclipse MicroProfile provides specifications for the most commonly used microservice patterns. This session presents a group of patterns that will be in explained and demoed live in a down-to-earth and easily understandable way.

Patterns covered include Service per Container, Externalized Configuration, Health Check API, Application Metrics, Circuit Breaker, Access Token, Distributed Tracing.

There will be live coding and demo of all technologies implementing the patterns.

B489790e1a844284d7cd1fa2cd6e021f?s=128

ivargrimstad

April 26, 2019
Tweet

Transcript

  1. Microservice Patterns Implemented by Eclipse MicroProfile Ivar Grimstad
 Principal Consultant,

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

  3. @ivar_grimstad #microservices Introduction The Patterns Summary

  4. @ivar_grimstad #JakartaEE #EE4J

  5. @ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE

  6. @ivar_grimstad #microservices M icroProfile 2.2 Februyary 12, 2019

  7. @ivar_grimstad #microservices The Patterns

  8. @ivar_grimstad #microservices 1. Microservice Architecture 2. Externalised Configuration 3. Health

    Check API 4. Application Metrics 5. Circuit Breaker 6. Access Token 7. Distributed Tracing 8. Service per Container
  9. @ivar_grimstad #microservices

  10. @ivar_grimstad #microservices Microservice Architectures #1

  11. @ivar_grimstad #microservices

  12. @ivar_grimstad #microservices

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

  14. @ivar_grimstad #microservices Monolithic Architecture Monolithic Application

  15. @ivar_grimstad #microservices Monolithic Architecture

  16. @ivar_grimstad #microservices Service A Service B Service C Application Call

    A Call B Call C Microservice Architecture
  17. @ivar_grimstad #microservices Microservice Architecture

  18. @ivar_grimstad #microservices Externalised Configuration #2

  19. @ivar_grimstad #microservices

  20. @ivar_grimstad #microservices

  21. @ivar_grimstad #microservices How to enable a service to run in

    multiple environments without modification?
  22. @ivar_grimstad #microservices Configuration for MicroProfile

  23. @ivar_grimstad #microservices System Properties System.getProperties() Environment Variables System.getenv() Application Configuration

    META-INF/microprofile-config.properties
  24. @ivar_grimstad #microservices DEMO

  25. @ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE

  26. @ivar_grimstad #microservices Health Check API #3

  27. @ivar_grimstad #microservices

  28. @ivar_grimstad #microservices

  29. @ivar_grimstad #microservices How to detect that a running service instance

    is unable to handle requests?
  30. @ivar_grimstad #microservices MicroProfile Health API

  31. @ivar_grimstad #microservices DEMO

  32. @ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE

  33. @ivar_grimstad #microservices Application Metrics #4

  34. @ivar_grimstad #microservices

  35. @ivar_grimstad #microservices

  36. @ivar_grimstad #microservices How to understand the behavior of an application

    and troubleshoot problems?
  37. @ivar_grimstad #microservices MicroProfile Metrics

  38. @ivar_grimstad #microservices DEMO

  39. @ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE

  40. @ivar_grimstad #microservices Circuit Breaker #5

  41. @ivar_grimstad #microservices

  42. @ivar_grimstad #microservices

  43. @ivar_grimstad #microservices How to prevent a network or service failure

    from cascading to other services?
  44. @ivar_grimstad #microservices

  45. @ivar_grimstad #microservices

  46. @ivar_grimstad #microservices DEMO

  47. @ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE

  48. @ivar_grimstad #microservices Access Token #6

  49. @ivar_grimstad #microservices

  50. @ivar_grimstad #microservices

  51. @ivar_grimstad #microservices How to communicate the identity of the requestor

    to the services that handle the request?
  52. @ivar_grimstad #microservices Basic Authentication

  53. @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!”}
  54. @ivar_grimstad #microservices OAuth 2.0

  55. @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!”}
  56. @ivar_grimstad #microservices JSON Web Token (JWT)

  57. @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!”}
  58. @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!”}
  59. @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
  60. @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!”}
  61. @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
  62. @ivar_grimstad #microservices DEMO

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

  64. @ivar_grimstad #microservices Distributed Tracing #7

  65. @ivar_grimstad #microservices

  66. @ivar_grimstad #microservices

  67. @ivar_grimstad #microservices How to understand the behavior of an application

    and troubleshoot problems?
  68. @ivar_grimstad #microservices

  69. @ivar_grimstad #microservices DEMO

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

  71. @ivar_grimstad #microservices Service per Container #8

  72. @ivar_grimstad #microservices

  73. @ivar_grimstad #microservices

  74. @ivar_grimstad #microservices How are services packaged and deployed?

  75. @ivar_grimstad #microservices Application Server (Container) Service C Service B Service

    A Configuration A Configuration B Configuration C
  76. @ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE Thin WAR

  77. @ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE UberJAR

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

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

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

  81. @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
  82. @ivar_grimstad #microservices

  83. @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
  84. @ivar_grimstad #microservices

  85. @ivar_grimstad #microservices

  86. @ivar_grimstad #microservices Hardware Operating System JVM UberJAR Hardware Operating System

    Native Application Hardware Operating System JVM Java EE Container Java EE Application docker run dukes docker run dukes docker run dukes JVM MicroProfile Container MicroProfile Application
  87. @ivar_grimstad #microservices DEMO

  88. @ivar_grimstad #MicroProfile #JavaEE #EE4J #JakartaEE

  89. @ivar_grimstad #microservices Summary

  90. @ivar_grimstad #microservices

  91. @ivar_grimstad #microservices 1. Microservice Architecture 2. Externalised Configuration 3. Health

    Check API 4. Application Metrics 5. Circuit Breaker 6. Access Token 7. Distributed Tracing 8. Service per Container
  92. @ivar_grimstad #microservices Microservice Architecture http://microservices.io Samples https://github.com/ivargrimstad/microservice-patterns Microprofile http://microprofile.io Jakarta

    EE https://jakarta.ee
  93. @ivar_grimstad #microservices cybercom.com