The Eclipse MicroProfile offers a development platform for users of Enterprise Java who want innovation and modern APIs.
This presentation covers some of the APIs available in the MicroProfile 1.2 specification as at November 2017
3. @croft#Devoxx #MicroProfile
What is MicroProfile?
• A collection of APIs
• Focused on, but not limited to, microservices
• A place for innovation
• A fast, time-boxed release cycle
• Community driven
4. @croft#Devoxx #MicroProfile
Why MicroProfile?
• Get involved in the future of Enterprise Java
• Java EE and the JCP are perceived as slow
• For your app
• The tech landscape is changing, microservice or not. MicroProfile
aims to provide tools to make the best use of new tech
5. @croft#Devoxx #MicroProfile
How do I get it?
• Choose your own adventure
• Payara Micro
• TomEE
• WildFly Swarm
• Open Liberty
• KumuluzEE
• Hammock
6. @croft#Devoxx #MicroProfile
What APIs do I get?
• MicroProfile 1.2
• Config 1.1
• Health Check 1.0
• Fault Tolerance 1.0
• JWT Propagation 1.0
• Metrics 1.0
7. @croft#Devoxx #MicroProfile
What APIs will I get?
• MicroProfile Future
• Open Tracing 1.0
• Open API 1.0
• TypeSafe Rest Client 1.0
• JSON-B 1.0
• Java EE 8 upgrades
• Maintenance Releases
UNCONFIRMED!
9. @croft#Devoxx #MicroProfile
Config 1.1
• Inject config values at runtime
• NOT a registry
• Values are read-only by design
• Specify your own config sources
• Ordinals for priority
• Higher number == higher priority
19. @croft#Devoxx #MicroProfile
Metrics 1.0
• @Counted
• monotonic
• Targets:
• Constructor
• Method
• Type
@Counted
public void serviceA() {
// only current
// invocations counted
}
@Counted(monotonic = true)
public void serviceB() {
// every invocation
// counted
}
20. @croft#Devoxx #MicroProfile
Metrics 1.0
• @Gauge
• unit
•Targets:
• Method
• Produces:
• Sampled value,
e.g. CPU temperature
@Gauge(unit = MetricUnits.MEGABYTES)
public long getHeapSize() {
return heapSize;
}
@Gauge(unit = MetricUnits.NONE)
public long getValue() {
return value;
}
21. @croft#Devoxx #MicroProfile
Metrics 1.0
• @Metered
• Targets:
• Constructor
• Method
• Type
• Produces:
• Mean throughput
• 1, 5, 15 minute moving avg
@Metered
public class MeteredBean {
public void serviceA() { ... }
public void serviceB() { ... }
}
@Metered
public void run(){
// do work
}
22. @croft#Devoxx #MicroProfile
Metrics 1.0
• @Timed
• Targets:
• Constructor
• Method
• Type
• Produces:
• Duration statistics
• Throughput statistics
@Timed
public class TimedBean {
public void serviceA() { ... }
public void serviceB() { ... }
}
@Timed
public void run(){
// do work
}
26. @croft#Devoxx #MicroProfile
Metrics 1.0
• Sample prometheus.yml
• Found in the Vote service of the
Microprofile-Conference
application
• Liberty’s implementation is
secured by default, hence the need
for authentication
scrape_configs:
- job_name: 'microprofile-conference-vote'
tls_config:
insecure_skip_verify: true
basic_auth:
username: confAdmin
password: microprofile
scheme: https
static_configs:
- targets: ['localhost:9443']
28. @croft#Devoxx #MicroProfile
Fault Tolerance 1.0
• Implements common design patterns
• All annotations can be used together
• @Asynchronous
• @Retry
• @Fallback
• @CircuitBreaker
• @Bulkhead
• @Timeout
• See the spec for details
29. @croft#Devoxx #MicroProfile
Fault Tolerance 1.0
• @Asynchronous
• Annotate method or class
• Method(s) invoked in separate thread
• MUST return a Future
• Assumes requests should be synchronous if not specified
36. @croft#Devoxx #MicroProfile
JWT Propagation 1.0
• Token-based authentication
• Easily validated without second round-trip
• JSON format data
• Uses claims to carry auth information about a subject
• Processing trivial with JSON-P
• Agreed set of standard claims for interoperability
37. @croft#Devoxx #MicroProfile
JWT Propagation 1.0
• MicroProfile JWT Tokens can...
• Be used for authentication
• Be used for authorization
• Be mapped to JSR375 IdentityStore
• Support additional IANA standard claims
• Support additional non-standard claims
• 2 new standard claims
• upn: user principal
• groups: token subject’s group memberships
39. @croft#Devoxx #MicroProfile
JWT Propagation 1.0
• @Claim
• Claims enum available for
standard claims
• Ambiguous uses throw
DeploymentException
• For complete details,
see the specification doc
@ApplicationScoped
public class MyEndpoint {
@Inject
@Claim(value = "exp",
standard = Claims.iat)
private Long timeClaim;
// Mixing exp with iat
// Throws exception
@Claim(standard = Claims.iss)
private Long timeClaim;
}
40. @croft#Devoxx #MicroProfile
Find Out More...
As a user...
• Choose your implementation!
• What specs does it support?
• Check the release notes…
• For the microprofile-bom
• For the individual specs
• Ask questions!
• In Gitter!
• In the Google Group!
41. @croft#Devoxx #MicroProfile
Find Out More...
As a contributor...
• What specifications are you interested in?
• An existing spec?
• Find the repository on GitHub (or on microprofile.io)
• Find the chat community on Gitter
• Find the hangout in the MicroProfile Calendar
• Something new?
• Start a discussion in the Google Group!
• Start coding in the Sandbox repository
• (PRs should be merged quickly)
43. @croft#Devoxx #MicroProfile
Questions?
• How does MicroProfile relate to EE4J?
• How big is MicroProfile planning to get?
• There are no implementation rules - could be composable
• There will be some interdepency though - e.g. Config API widely
reused
• What about breaking changes?
• MicroProfile is about innovation primarily. Breaking changes will be
avoided where possible, but not if it limits progress.