En esta sesión los asistentes presenciaron la base teórica y práctica para la creación de micro servicios con Java, JakartaEE, MicroProfile utilizando TomEE como servidor de aplicaciones.
6. @CesarHgt @tomitribejugbaq.org
A microservice architectural style is an approach to
developing a single application as a suite of small services,
each running in its own process and communicating with
lightweight mechanisms, often an HTTP resource API.
— Martin Fowler
12. @CesarHgt @tomitribejugbaq.org
● 39% plan to use Java to build microservices in the next year
● Using Java for cloud native applications
○ 44% Spring/Spring Boot ( - 13%)
○ 35% Jakarta EE
● Architectural Approach
○ 39% Microservices
○ 25% Monolithic (2x since 2019)
○ 23% Hybrid
Microservices and Cloud-native
Source: Jakarta EE Developer Survey 2020 - The Eclipse Foundation’s global survey of 2180 Java developers.
○ 29% MicroProfile
○ 16% Quarkus
14. @CesarHgt @tomitribejugbaq.org
Eclipse MicroProfile
● An open-source community specification
● Focus on Enterprise Java microservices
● Generates: SPEC, API, and TCK.
● https://microprofile.io
● Implemented by different vendors.
21. @CesarHgt @tomitribejugbaq.org
TomEE JAX-RS (~ Microprofile)
TomEE JAX-RS Microprofile
Java Server Pages
(JSP)
Java Server Faces
(JSF)
Java Transaction
API (JTA)
Bean Validation
Enterprise
JavaBeansJavaMail API
Java API for RESTful
Web Services
(JAX-RS)
Java Persistence
API (JPA)
Contexts and
Dependency
Injection (CDI)
Java Servlets
Java Authentication
and Authorization
Service (JAAS)
Java Authorization
Contract for
Containers (JACC)
28. @CesarHgt @tomitribejugbaq.org
Health Feature
● Probes state of services and resources.
● Infrastructure benefits
● It’s intended as a machine to machine (M2M) mechanism
● Examples: CloudFoundry Health Checks and Kubernetes Liveness and
Readiness Probes.
29. @CesarHgt @tomitribejugbaq.org
Familiarize yourself with the API
● Default endpoints:
○ http://host:port/health
○ http://host:port/<app-context>/health
● General output:
○ {"checks":[],"outcome":"UP","status":"UP"}
38. @CesarHgt @tomitribejugbaq.org
● Where to store configurations?
○ The default config sources always available by default are:
■ System properties (ordinal=400)
■ Environment properties (ordinal=300)
■ /META-INF/microprofile-config.properties (ordinal=100)
○ The priority will be used to order the ConfigSource implementations to search for
the configuration key.
MicroProfile Configuration
41. @CesarHgt @tomitribejugbaq.org
Difference to health checks
● Health checks
○ "Is my application still running ok?".
● Metrics:
○ Determine the overall the microservices health.
○ Provide long term trend data.
46. @CesarHgt @tomitribejugbaq.org
What is JWT?
● Stands for JSON Web Token.
● It’s a JSON-based text format for exchanging information between
parties.
● It’s an open standard specified under RFC 7519.
● Standards such as OpenID Connect and OAuth 2 use JWT to represent
their own tokens.
48. @CesarHgt @tomitribejugbaq.org
● Standard
● Interoperability across the enterprise and vendors that favors
microservices development.
● JWT can be both verified and propagated by each microservice.
Why do we need MicroProfile JWT?
54. @CesarHgt @tomitribejugbaq.org
The Rise of Resilience and Eventual Consistency
● Distributed systems
● All-or-nothing approach.
● Resilience
● Design patterns under the Fault Tolerance umbrella:
○ Bulkhead – isolate failures in part of the system.
○ Circuit breaker – offer a way to fail fast.
○ Retry – define criteria on when to retry.
○ Fallback – provide an alternative solution for a failed execution.
○ Timeout
55. @CesarHgt @tomitribejugbaq.org
@Timeout @Retry
import org.eclipse.microprofile.faulttolerance.Timeout;
@Timeout(500)
public String callSomeServiceLogic() {...}
@Retry(retryOn = IOException.class)
public String callSomeServiceLogic() {...}
@Timeout(500)
@Retry(maxRetries = 1)
public String callSomeService() {...}