Optimizing Enterprise Java for a Microservices Architecture Otávio Santana @otaviojava otaviojava@apache.org
Enterprise Java Standards History J2EE 1.2 J2EE 1.3 J2EE 1.4 Java EE 5 Java EE 6 Java EE 7 Java EE 8 2015 2000 2005 2010 2020 Release Cadence
● JCP Members ● JCP EC ● JSR ● Standards
Fundamental Shifts in Computing Cloud ● Reduce time to market ● Address unpredictable loads ● Pay as you go ● Containerization Microservices ● Deliver new features more quickly ● Smaller, more agile teams ● Deliver business features as discrete services ● Scale services independently
MicroProfile Background ● Began as a collection of independent discussions ○ Many innovative “microservices” efforts in existing Java EE projects ■ WildFly Swarm ■ WebSphere Liberty ■ Payara ■ TomEE ○ Projects already leveraging both Java EE and non-Java EE technologies ○ Creating new features/capabilities to address microservices architectures ● Quickly realized there is common ground ● Java EE technologies are already being used for microservices, but we can do better
Profile
MicroProfile Release Philosophy Rapidly iterate Build Standardize Release 1.0 and innovate consensus JAX-RS CDI JSON-P S e p t 2 0 1 6
Bridging Community and Standards Vendor Choice Broad Collaboration Implementation Choice Encouraged experimentation Application Portability Fail Fast Backwards Compatibility Rapid innovation Reduced Risk
An Eclipse Foundation Project ● Meritocracy; vendor neutrality ● MicroProfile leadership can change over time ● Legal and technical infrastructure ● Trademark Ownership ● Accepts Apache License
MicroProfile 1.1 Underway Configuration 1.0 Security: JWT Token Exchange 1.0 Second Quarter 2017! Health Check 1.0 Fault Tolerance 1.0 (Stretch goal)
Configuration 1.0 @ApplicationScoped public class InjectedConfigUsageSample { @Inject private Config config; @Inject @ConfigProperty(name="myprj.some.url") private String someUrl; @Inject @ConfigProperty(name="myprj.some.port") private Optional< Integer > somePort; @Inject @ConfigProperty(name="myprj.some.dynamic.timeout", defaultValue="100") private javax.inject. Provider < Long > timeout; }
Security: JWT Token Exchange 1.0 @Priority(Priorities.AUTHENTICATION) public class JWTAuthFilter implements ContainerRequestFilter{ @Override public void filter(ContainerRequestContext requestContext) throws IOException { String authHeaderVal = requestContext.getHeaderString("Authorization"); if (authHeaderVal.startsWith("Bearer")){ try { validate(authHeaderVal.split(" ")[1]); } catch (InvalidJwtException ex) { requestContext.abortWith(Response.status(Response.Status.UNAUTHORIZED).build()); } } else { requestContext.abortWith(Response.status(Response.Status.UNAUTHORIZED).build()); } }
Health Check 1.0 @Path("/app") public class HealthCheckResource { @ApplicationScoped public class HealthChecks { @GET @Path("/diskspace") @Produces @Health @Health public HealthStatus checkDiskspace() { public HealthStatus checkDiskspace() { [...] [...] } } @GET @Produces @Path("/something-else") @Health @Health public HealthStatus checkSomethingElse() { public HealthStatus checkSomethingElse() { [...] [...] } } } }
Fault Tolerance 1.0 (Stretch goal) @ApplicationScoped public class FaultToleranceBean { CircuitBreaker cb = FaultToleranceFactory.getInstance(CircuitBreaker.class) @Retry(maxRetries = 2) .withFailureThreshold(3, 10) public Runnable doWork() { .withSuccessThreshold(5) Runnable mainService = () -> serviceA(); .withDelay(1, TimeUnit.MINUTES); return mainService; Connection connect = execution.with(cb).run( this ::connect); } } }
Feature Backlog* - Help us prioritize [1 of 2] ● Container API ● Configuration ● Microservic-y annotations ● Metrics/Monitoring (Ex: @CircuitBreaker) ● WebSockets ● Testing ● JSON-B ● Distributed Logging ● Bean Validation ● Distributed Tracing ● JPA ● OAuth2/OpenID Connect ● JTA ● Microservice Security ● Concurrency Utilities for ● Service Discovery Java EE ● Health Check * Some Items may be removed due to lack of interest
Feature Backlog* - Help us prioritize [2 of 2] ● Messaging / Eventing ● JDK 8 ● Asynchronous/Reactive Lambda+Streams Support / Patterns ● EJB Lite ● Integration with Reactive / ● Servlets Eventing systems ● HTTP/2 ● Big Data/NoSQL strong & ● Startup Time weak consistency support ● Disk Space ● NetFlix OSS Integration ● Memory ● JCache ● Uber-jar ● Java 9 Modularity * Some Items may be removed due to lack of interest
Release Schedule MicroProfile Move to MicroProfile MicroProfile 1.0 Foundation 1.1 1.2 Sep 2016 Q4 2016 2017 2017
TomEE
DEMO
Join the Community!
Join the Discussion! https://groups.google.com/forum/#!forum/microprofile
Resources ● MicroProfile.io ● MicroProfile Discussion Forum bit.ly/MicroProfileForum MicroProfile Examples ● https://github.com/microprofile/microprofile-samples
Otávio Santana @otaviojava otaviojava@apache.org
Recommend
More recommend