Emily Jiang, WebSphere Application Server, CDI Development Lead, IBM Cloud @emilyfhjiang
While there are likely a dozen or more Java-based microservice / cloud native initiatives in the industry,
Eclipse MicroProfile provides a platform for Java developers to collaborate and innovate on areas of
common interest. This BOF will give a short overview of MicroProfile and how it plans to optimize
microservices for Enterprise Java, followed by a short Q&A to answer any clarifying questions, and the
remainder of the time spent on collaborating to prioritize features for the next release.
While MicroProfile's first release is founded in Java EE (CDI + JSON-P + JAX-RS), it is not intended to
remain a subset of Java EE 7 (or 8). The intent is to collaborate and innovate as a community in the
context of a microservices architecture across the 5 (and growing) MicroProfile implementations today.
The end goal of MicroProfile is to feed the Java Community Process (JCP) with JSR submissions backed
by well-thought-out concepts and even implementations that developers and enterprises can rely on.
Come collaborate with your fellow MicroProfilers to move Enterprise Java microservices forward.
Eclipse MicroProfile: Accelerating the adoption of Java Microservices
1. #DevoxxUS
Optimizing Enterprise Java
for a Microservices Architecture
John Clingan, middle-aged Java EE guy and MicroProfile-r
Emily Jiang, totally awesome MicroProfile engineer
Eclipse
2. #DevoxxUS
Agenda
MicroProfile Overview (~10 Minutes)
Example Specs - From concept to implementation (10 minutes)
Collaborate (Until they kick us out or we want to go for a beer)
4. #DevoxxUS
What is MicroProfile?
A community of individuals, organizations, and vendors …
… collaborating within an open source (Eclipse) project ….
… to bring microservices to the Enterprise Java
community
7. #DevoxxUS
Innovation vs Standardization
Spec Lead controls pace
(Open Source) Project Focused Standard (JSR) focused
(Java EE)
Large multi-feature releasesIncremental feature release
(MicroProfile)
Community controls pace
9. #DevoxxUS
MicroProfile 1.0 (Sep, 2016)
Contexts and Dependency Injection (CDI 1.1)
+
Java API for RESTful Web Services (JAX-RS 2.0)
+
Java API for JSON Processing (JSON-P 1.0)
13. #DevoxxUS
Configuration
● Discussed with a formal proposal in the MicroProfile mailing list
(https://groups.google.com/forum/#!topic/microprofile/VJEEAOsVj
5E[26-50])
● After the proposal was accepted, a repository was created to
draft APIs/SPIs (https://github.com/eclipse/microprofile-config/)
15. #DevoxxUS
MicroProfile Java Prog. Model - Configuration
Using CDI Injection
@Inject Config config; Inject all config properties that the class
can see
@Inject
@ConfigProperty(name=“myProp”
defaultValue=“blah”)
String prop1;
Inject the value of the property called
“myProp”. The value of prop1 will not be
refreshed. Suitable for static properties
and used on the RequestScoped beans.
@Inject
@ConfigProperty(name=“myProp”
defaultValue=“blah”)
Provider<String> prop1
Inject the value of the property called
“myProp” and it picks up the dynamic
changes.
16. #DevoxxUS
MicroProfile Java Prog. Model - Configuration
Programmatic lookup
ConfigProvider.getConfig(); The config object containing all
properties that the class owner can
see.
ConfigProvider.getBuilder()
.addDefaultSources()
.withSources(…).build();
Create a custom config object
17. #DevoxxUS
MicroProfile Java Prog. Model - Configuration
● The property file, microprofile-config.properties, packaged in the application can be
overwritten by :
○ System variables (400 as the default priority)
○ Environment variables (300 as the default priority) or
○ a custom property files with a higher priority than microprofile-config.properties
(100 as the default priority).
18. #DevoxxUS
MicroProfile Java Prog. Model - config
● Plan to finalise the current APIs/SPIs and release the Config 1.0
by mid April
● Then work on the new features of Config 1.1
● Join in the Config discussion
● Join in the Config hangout – on Thursdays
19. #DevoxxUS
MicroProfile Java Prog model –
Fault Tolerance
● Proposal discussion:
https://groups.google.com/forum/#!topic/microprofile/ESs9L3z08o
A
● Prototype (inspired by Failsafe): https://github.com/Emily-
Jiang/microprofile-faultTolerance-incubation
20. #DevoxxUS
MicroProfile Java Prog model –
Fault Tolerance
Retry The request should have a retry to recover from temporary
glitches
Fallback The request should have a fallback operation if retry fails
Timeout The request must have a timeout, to prevent from waiting
indefinitely
Circuit Breaker The request must prevent from repeating timeouts
Bulkhead One part of application failure must not bring the whole
application down
21. #DevoxxUS
Fault Tolerance - Fallback Retry
Set up retry policy and wrap the call with the policy and specify
the fallback operation
FaultToleranceFactory.getFaultToleranceType(RetryPolicy.class);
Duration delay = Duration.ofSeconds(1);
retryPolicy =
retryPolicy.retryOn(Exception.class).withDelay(delay)
.withMaxRetries(3);
Runnable fallbackService = () -> serviceB();
executor.with(retryPolicy).withFallback(fallbackService)
.run(mainService);
22. #DevoxxUS
Fault Tolerance - Circuit Breaker Timeout
Fail-fast, temporarily disable the running of a service
circuitBreaker =
FaultToleranceFactory.getFaultToleranceType(CircuitBreaker.class);
circuitBreaker =
circuitBreaker.withTimeout(timeout).withFailureThreshold(3)
.withSuccessThreshold(2)
.withDelay(delay);
Callable<Object> mainService = () -> serviceA();
Executor executor =
FaultToleranceFactory.getFaultToleranceType(Executor.class);
executor.with(circuitBreaker).get(mainService);
23. #DevoxxUS
Fault Tolerance - Bulkhead
Limit the number of concurrent calls to a service
ThreadPoolExecutor tpexecutor = new ThreadPoolExecutor(
poolSize, poolSize, 0,
TimeUnit.SECONDS,
new ArrayBlockingQueue<Runnable>(10));
bulkhead = bulkhead.withThread(tpexecutor);
executor.with(bulkhead) .run(mainService);
24. #DevoxxUS
MicroProfile Java Prog model –
Fault Tolerance
● Non-CDI approach was left out of the first release but focus on CDI-first
approach
● Discussion the CDI-first approach ongoing
● Use Interceptor to apply policy and use annotation to config policy
Java EE has been an extremely successful platform. The JCP has been the steward of over 20 compatible implementations over its nearly 20 year history, resulting in a $4B industry. These are just some of the Java EE compatible implementations that exist.
In its early stages, J2EE grew somewhat quickly (perhaps too quickly) as the platform needed to address the immediate needs of the enterprise. Beginning with Java EE 5 in 2006, the pace began to slow as the platform began to mature. Java EE is now following the slower release cadence that a standards organization typically reflects. A standards-based release cadence by design does not address ew and rapid innovations.
MicroProfile 1.1 is underway, and scheduled for the 2nd quarter of 2017. The community has decided to focus this release on Configuration, Security (JWT Token Exchange), Health Check, and Fault Tolerance.
Configuration: Separates (externalizes) a microservice from its configuration.
Health Check: Specifies a REST endpoint with service health information. Enables cloud infrastructure to detect the health of a service. If a service is unhealthy, a cloud runtime can restart (or fail and re-create) a service instance
Fault Tolerance: APIs that cover popular microservice programming patterns, including Fallback, Circuit Breakers, and Bulkheads