Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Eclipse MicroProfile para el desarrollador ocupado

362 views

Published on

Un recorrido sobre Java EE 8 y Eclipse MicroProfile para la creación de microservicios

Published in: Technology
  • Be the first to comment

Eclipse MicroProfile para el desarrollador ocupado

  1. 1. Eclipse MicroProfile para el desarrollador ocupado Jorge Cajas - V´ıctor Orozco 11 de Abril de 2019 @cajasmota - @tuxtor 1
  2. 2. Java EE - MicroProfile - Spring Boot - Docker 2
  3. 3. ¿Microservicios?
  4. 4. ¿Microservicios? ¿Necesito migrar todo a microservicios? ¿Que pasa si no utilizo microservicios? ¿Me estoy volviendo viejo? 3
  5. 5. Reactive applications Aplicaciones reactivas Microservicios son una (de muchas) herramienta para creaci´on de aplicaciones reactivas 4
  6. 6. Monolito - Escalabilidad Figura 1: Mon´olito 5
  7. 7. ESB Figura 2: ESB 6
  8. 8. Microservicios Figura 3: Microservicios 7
  9. 9. Java EE 8
  10. 10. Java EE 8 8
  11. 11. Java EE 8 Java EE 8 • Integraci´on JSF-CDI • Integraci´on JMS-CDI • HTTP/2 • JSON-B • Security • JAX-RS Reactivo 9
  12. 12. Java EE 8 - Comunidad Java EE 10
  13. 13. Eclipse MicroProfile
  14. 14. Eclipse MicroProfile Figura 4: Credito: Reza Rahman 11
  15. 15. Eclipse MicroProfile 12
  16. 16. Eclipse MicroProfile 13
  17. 17. Eclipse MicroProfile - Implementaciones Bibliotecas • SmallRye (Red Hat) • Hammock • Apache Geronimo • Fujitsu Launcher JEAS - Fat Jar • Dropwizard • KumuluzEE • Helidon (Oracle) • Open Liberty (IBM) • Apache Meecrowave • Thorntail (Red Hat) • Quarkus (Red Hat) 14
  18. 18. Eclipse MicroProfile - Implementaciones Micro server • Payara Micro • TomEE Plume Full server • Payara Application Server • JBoss Application Server / Wildfly Application Server • WebSphere Liberty (IBM) https://wiki.eclipse.org/MicroProfile/Implementation 15
  19. 19. Eclipse MicroProfile on Payara 5 <dependency > <groupId >org.eclipse.microprofile </ groupId > <artifactId >microprofile </ artifactId > <type >pom </type > <version >2.0.1 </ version > <scope >provided </scope > </dependency > 16
  20. 20. Config 17
  21. 21. Config @Inject @ConfigProperty(name = "omdbservice.url") String omdbDaemonServiceUrl ; Ext. de la configuraci´on (VM, Docker, Kubernetes) 18
  22. 22. Fault Tolerance 19
  23. 23. Metrics 20
  24. 24. Fault Tolerance + Metrics • Fault Tolerance depende de la existencia de metricas, las metricas se exponen mediante Metrics 21
  25. 25. Fault tolerance Reglas de evaluaci´on y alternativas • Circuit Breaker • Bulkhead • Retry • Timeout • Fallback 22
  26. 26. Fault tolerance - Fallback, Timeout @GET @Path("/{id:[a-z]*[0 -9][0 -9]*}") @Fallback(fallbackMethod = "findByIdFallBack") @Timeout(TIMEOUT) public Response findById(@PathParam("id") final String imdbId) { ... } public Response findByIdFallBack (@PathParam("id") final String imdbId) { ... } 23
  27. 27. M´etricas • JSON or OpenMetrics (Prometheus) • Vendor • Base • Application ¿Cuales? • Counted • Gauge • Metered • Timed • Histogram 24
  28. 28. Metrics - Counted @Inject @Metric Counter failedQueries; @GET @Path("/{id:[a-z]*[0 -9][0 -9]*}") @Fallback(fallbackMethod = "findByIdFallBack") @Timeout(TIMEOUT) public Response findById(@PathParam("id") final String imdbId) { ... } public Response findByIdFallBack (@PathParam("id") final String imdbId) { ... failedQueries.inc(); } 25
  29. 29. Metrics - Gauge Inc-dec en tiempo real @Gauge(unit = "ExternalDatabases",name = "movieDatabases", absolute = true) public long getDatabases () { return 99; //Any value } /metrics/application/movieDatabases 26
  30. 30. Metrics - Metered Events rate @Metered(name = " moviesRetrieved ", unit = MetricUnits.MINUTES , description = "Metrics to monitor movies", absolute = true) public Response findExpandedById ( @PathParam("id") final Long id) /metrics/application/movieDatabases 27
  31. 31. Metrics- Timed Desempe˜no y retraso @Timed(name = "moviesDelay", description = "Time to retrieve a movie", unit = MetricUnits.MINUTES , absolute = true) public Response findExpandedById ( @PathParam("id") final Long id) /metrics/application/moviesDelay 28
  32. 32. Metrics - Histogram Distribuciones @Inject MetricRegistry registry; @POST @Path("/add/{ attendees}") public Response addAttendees( @PathParam("attendees") Long attendees) { Metadata metadata = new Metadata("matrix attendees", MetricType.HISTOGRAM ); Histogram histogram = registry.histogram(metadata ); histogram.update(attendees ); return Response.ok(). build (); } 29
  33. 33. Health Check 30
  34. 34. Health Check ¿Estas vivo? @Override public HealthCheckResponse call () { return HealthCheckResponse .named("TaVivoAinda") .withData("key1", "val1") .withData("key2", "val2") .up() .build (); } 31
  35. 35. JWT 32
  36. 36. JWT @LoginConfig(authMethod = "MP-JWT") public class ApplicationConfig extends Application { } @Inject private JsonWebToken jwtPrincipal; @Inject @Claim("email") private String email; 33
  37. 37. TypeSafe 34
  38. 38. TypeSafe @Path("/playlist") @Consumes("application/json") public interface MusicPlaylistService { @GET List <String > getPlaylistNames (); @PUT @Path("/{ playlistName}") long updatePlayList(@PathParam("playlistName") String name , List <Song > playlist) throws UnknownPlaylistException ; } 35
  39. 39. Demo
  40. 40. EE + MicroProfile - Demo Java 8, JAX-RS, CDI, EJB, MicroProfile https://github.com/tuxtor/payara-demo https://github.com/tuxtor/omdb-demo 36
  41. 41. Payara Micro - Java EE 8 Stacks tradicionales • EJB • JTA • JAX-RS • CDI 37
  42. 42. EE + MicroProfile - Demo MicroProfile: JAX-RS, CDI, Config, Fault Tolerance, Metrics Payara Micro: EJB, JTA Fatores externos: Location, Deployment, Orchestation, Balancing, Consistency 38
  43. 43. 12 factores cloud native (Heroku) Microprofile • Config • Backing service • Disposability Cloud • Codebase (Git-Flow) • Dependencies (Maven) • Build, Release, Run • Processes (Pipelines) • Port binding • Concurrency (Docker - k8s) • Dev / Prod parity • Logs • Admin process 39
  44. 44. Oracle Cloud 40
  45. 45. Oracle Cloud 41
  46. 46. Oracle Cloud 42
  47. 47. Oracle Cloud 43
  48. 48. V´ıctor Orozco • me@vorozco.com • @tuxtor • http://vorozco.com • http://tuxtor.shekalug.org This work is licensed under a Creative Commons Attribution-ShareAlike 3.0. 44

×