microservices
play

Microservices Are your Frameworks ready? Martin Eigenbrodt | - PowerPoint PPT Presentation

Microservices Are your Frameworks ready? Martin Eigenbrodt | martin.eigenbrodt@innoq.com Alexander Heusingfeld | alexander.heusingfeld@innoq.com Microservices? Levels of Architecture Domain architecture Domain architecture Macro (technical)


  1. Microservices Are your Frameworks ready? Martin Eigenbrodt | martin.eigenbrodt@innoq.com Alexander Heusingfeld | alexander.heusingfeld@innoq.com

  2. Microservices?

  3. Levels of Architecture

  4. Domain architecture

  5. Domain architecture Macro (technical) architecture

  6. JRuby C# Groovy 
 Scala Clojure Java

  7. NoSQL RDBMS K/V NoSQL 
 RDBMS RDBMS/DWH DocDB

  8. NoSQL RDBMS K/V NoSQL 
 RDBMS RDBMS/DWH DocDB Micro architecture

  9. Challenges

  10. Challenges

  11. Challenges > many services to take care of

  12. Challenges > many services to take care of > distributed system

  13. Challenges > distributed con fj guration > service registration & discovery > resilience > fast, automated deployment > metrics

  14. Macro- vs. Micro Architecture

  15. Frameworks

  16. Dropwizard

  17. Dropwizard > Glue Code for well known libraries > Java

  18. Dropwizard libraries

  19. Dropwizard libraries > Jetty

  20. Dropwizard libraries > Jetty > Jersey

  21. Dropwizard libraries > Jetty > Jersey > Metrics

  22. Dropwizard libraries > Jetty > JDBI > Logback > Jersey > Liquibase > Hibernate > Metrics Validator > Freemarker & Mustache > Jackson > Apache Http Client > Joda > Guava

  23. Spring Boot and Spring Cloud

  24. Spring Boot

  25. Spring Boot > convention over con fj guration approach

  26. Spring Boot > convention over con fj guration approach > Java, Groovy or Scala

  27. Spring Boot > convention over con fj guration approach > Java, Groovy or Scala > self-contained jar or war

  28. Spring Boot > convention over con fj guration approach > Java, Groovy or Scala > self-contained jar or war > tackles dependency-hell via pre-packaging

  29. Spring Cloud

  30. Spring Cloud > umbrella project for cloud connectors

  31. Spring Cloud > umbrella project for cloud connectors > On top of Spring Boot

  32. Spring Cloud > umbrella project for cloud connectors > On top of Spring Boot > con fj g server for distributed con fj guration

  33. Spring Cloud > umbrella project for cloud connectors > On top of Spring Boot > con fj g server for distributed con fj guration > annotations for service-discovery & resilience

  34. Play 2

  35. Play 2 > Java or Scala > based on Akka > strong async support

  36. Con fj guration

  37. Play - Typesafe Con fj g

  38. Play - Typesafe Con fj g > Con fj g Library used by akka, play and other

  39. Play - Typesafe Con fj g > Con fj g Library used by akka, play and other > HOCON - JSON Data Model + syntactic sugar

  40. Play - Typesafe Con fj g > Con fj g Library used by akka, play and other > HOCON - JSON Data Model + syntactic sugar > override via system property

  41. Play - Typesafe Con fj g > Con fj g Library used by akka, play and other > HOCON - JSON Data Model + syntactic sugar > override via system property > rich merge and include possibilities

  42. 
 Spring Boot @ComponentScan 
 @EnableAutoConfiguration 
 public class OrderApp { 
 public static void main(String[] args) { 
 SpringApplication. run (OrderApp. class , args); 
 } 
 }

  43. 
 Spring Boot @ComponentScan 
 @EnableAutoConfiguration 
 public class OrderApp { 
 public static void main(String[] args) { 
 SpringApplication. run (OrderApp. class , args); 
 } 
 }

  44. 
 Spring Boot @ComponentScan 
 @EnableAutoConfiguration 
 public class OrderApp { 
 public static void main(String[] args) { 
 SpringApplication. run (OrderApp. class , args); 
 } 
 } > HTTP resource “/autocon fj g” shows all properties

  45. 
 Spring Boot @ComponentScan 
 @EnableAutoConfiguration 
 public class OrderApp { 
 public static void main(String[] args) { 
 SpringApplication. run (OrderApp. class , args); 
 } 
 } > HTTP resource “/autocon fj g” shows all properties > overwrite via application.properties or CLI parameter

  46. 
 Spring Boot @ComponentScan 
 @EnableAutoConfiguration 
 public class OrderApp { 
 public static void main(String[] args) { 
 SpringApplication. run (OrderApp. class , args); 
 } 
 } > HTTP resource “/autocon fj g” shows all properties > overwrite via application.properties or CLI parameter > con fj guration in git? -> Check spring-cloud con fj gserver

  47. Http Client

  48. Dropwizard public Product resolveProduct(String url) { Product product = client.resource(url) .accept(MediaType.APPLICATION_JSON).get(Product.class); return product; }

  49. Spring Boot public Product resolveProduct(String url) { return restTemplate.getForEntity(url, Product.class); 
 }

  50. Play WS.url(apiUrl).get.map { response => response.json.as[List[Bestseller]] }.recover { case e => List() }

  51. Service Discovery

  52. Service Discovery Service Registry 1. register service ("myself") 2. discover service instances & heartbeat Service Service 3. call service instance Client Service

  53. 
 Spring Cloud @ComponentScan 
 @EnableAutoConfiguration 
 @EnableDiscoveryClient 
 public class OrdersApp { 
 public static void main(String[] args) { 
 SpringApplication.run(OrdersApp. class , args); 
 } 
 }

  54. 
 Spring Cloud @ComponentScan 
 @EnableAutoConfiguration 
 @EnableDiscoveryClient 
 public class OrdersApp { 
 public static void main(String[] args) { 
 SpringApplication.run(OrdersApp. class , args); 
 } 
 }

  55. 
 Spring Cloud @ComponentScan 
 @EnableAutoConfiguration 
 @EnableDiscoveryClient 
 public class OrdersApp { 
 public static void main(String[] args) { 
 SpringApplication.run(OrdersApp. class , args); 
 } 
 }

  56. Service Discovery with Sidecar Service Registry 4. discover service instances 2. register service ("myself") & heartbeat 5. call service instance 3. Sidecar Sidecar Client Service 1. health check

  57. Resilience

  58. Resilience > isolate Failure > apply graceful degradation > be responsive in case of failure

  59. Request service closed http:/ /en.wikipedia.org/wiki/Circuit_breaker

  60. Request service closed Request service open http:/ /en.wikipedia.org/wiki/Circuit_breaker

  61. Request service closed Request service open half- service Request open http:/ /en.wikipedia.org/wiki/Circuit_breaker

  62. > Provides Command-oriented Integration of Services > Introduces Circuit Breaker, Bulkheads and Isolation > Decouples from Service-dependencies > Provides metrics-facility to protect from failures

  63. Hystrix & Dropwizard public class CommandInDropwizard extends TenacityCommand<Product> { @Override protected Product run() throws Exception { Product product = client.resource(url) .accept(MediaType.APPLICATION_JSON).get(Product.class); return product; } protected Product getFallback() { return FALLBACK_PRODUCT } }

  64. Hystrix & Dropwizard public class CommandInDropwizard extends TenacityCommand<Product> { @Override protected Product run() throws Exception { Product product = client.resource(url) .accept(MediaType.APPLICATION_JSON).get(Product.class); return product; } protected Product getFallback() { return FALLBACK_PRODUCT } }

  65. Hystrix & Dropwizard public class CommandInDropwizard extends TenacityCommand<Product> { @Override protected Product run() throws Exception { Product product = client.resource(url) .accept(MediaType.APPLICATION_JSON).get(Product.class); return product; } protected Product getFallback() { return FALLBACK_PRODUCT } }

  66. Hystrix & Dropwizard public class CommandInDropwizard extends TenacityCommand<Product> { @Override protected Product run() throws Exception { Product product = client.resource(url) .accept(MediaType.APPLICATION_JSON).get(Product.class); return product; } protected Product getFallback() { return FALLBACK_PRODUCT } }

  67. Hystrix & Dropwizard ResolveProductCommand command = new ResolveProductCommand(client, url); Product product = command.execute();

  68. Spring Cloud Hystrix @HystrixCommand(fallbackMethod = “fallbackProduct" ) private Pair<String, ResponseEntity<Product>> resolveProduct(String productUri) { 
 final RestTemplate restTemplate = new RestTemplate(); 
 return new Pair(productUri, restTemplate.getForEntity(productUri, Product. class )); 
 } private Pair<String, ResponseEntity<Product>> fallbackProduct(String productUri) { 
 final Product product = new Product(productUri, null , BigDecimal. ZERO ); 
 final ResponseEntity<Product> response = new ResponseEntity<Product>(product, PARTIAL_CONTENT ); 
 return new Pair(productUri, response); 
 }

Recommend


More recommend