際際滷

際際滷Share a Scribd company logo
1@emilyfhjiang
A new and smart way to develop cloud-native
microservices - MicroProfile
STSM, Liberty Architect of Microservicers, Advocate
Liberty leadArchitect for MicroProfile and CDI, IBM
@emilyfhjiang
2@emilyfhjiang
About Emily Jiang
2
Java Champion
STSM, IBM, Liberty Lead Architect for MicroProfile and CDI
Leads MicroProfile Config, Fault Tolerance, Service Mesh
Co-spec lead for Config JSR
CDI Expert Group
Based in IBMs Hursley lab, UK
Email: emijiang@uk.ibm.com
https://www.linkedin.com/in/emily-jiang-60803812/
3@emilyfhjiang
Cloud demands:
Small runtime memory footprint
Small deployment sizes
Fast starting applications
No resource usage when idle
4@emilyfhjiang
Java in Cloud
Small footprint
Fast startup
Qick/immediate rampup
5@emilyfhjiang
Java in Cloud
Hotspot OpenJ9 OpenJ9 -Xshareclasses -
Xquickstart
Hotspot OpenJ9 OpenJ9 -Xshareclasses -Xquickstart
Footprint is 60% smaller with OpenJ9
Hotspot OpenJ9 OpenJ9 -Xshareclasses -
Xquickstart
Hotspot OpenJ9 OpenJ9 -Xshareclasses -Xquickstart
Startup time is 30% faster with
OpenJ9 Xshareclasses -Xquickstart
5
Java in Cloud
Hotspot OpenJ9 OpenJ9 -Xshareclasses -
Xquickstart
Hotspot OpenJ9 OpenJ9 -Xshareclasses -Xquickstart
Footprint is 60% smaller with OpenJ9
Hotspot OpenJ9 OpenJ9 -Xshareclasses -
Xquickstart
Hotspot OpenJ9 OpenJ9 -Xshareclasses -Xquickstart
Startup time is 30% faster with
OpenJ9 Xshareclasses -Xquickstart
6@emilyfhjiang
cloud-native microservice
1. RESTful  like cattle not pet, communicative
2. Configurable
3. Fault tolerance
4. Can be discovered
5. Secure
6. Traceable, monitorable
7. Able to communicate with the cloud infrastructure
7@emilyfhjiang
Community
Driven
Lightweight, Iterative
Processes
Specs, APIs, TCKs
NO Reference
Implementation
8@emilyfhjiang
Open specifications
Wide vendor support
REST services
OpenAPI support
Security
Fault Tolerance
Configuration
Metrics
Health
Open Tracing
https://wiki.eclipse.org/MicroProfile/Implementation
Quarkus
9@emilyfhjiang
openliberty.io
Jan Dec
19.0.0.2
19.0.0.1 19.0.0.3
4-week release cadence
10@emilyfhjiang
10
MicroProfile 1.0 (Fall 2016)
jaxrs-2.0
cdi-1.2
jsonp-1.0
MicroProfile 1.1 (August 2017)
microProfile-1.0
mpConfig-1.0
MicroProfile 1.2 (Sept 2017)
microProfile-1.1
mpConfig-1.1
mpFaultTolerance-1.0
mpHealth-1.0
mpMetrics-1.0
mpJwt-1.0
2017
2018
MicroProfile 1.3 (Dec 2017)
MicroProfile 1.2
mpConfig-1.2
mpMetrics-1.1
mpOpenApi-1.0
mpOpenTracing-1.0
mpRestClient-1.0
MicroProfile 1.4 (June 2018)
MicroProfile 1.3
mpConfig-1.3
mpFaultTolerance-1.1
mpJwt-1.1
mpOpenTracing-1.1
mpRestClient-1.1
2019
MicroProfile 2.0.1 (July 2018)
MicroProfile 1.4
jaxrs-2.1 // Java EE 8
cdi-2.0 // Java EE 8
jsonp-1.1 // Java EE 8
jsonb-1.0 // Java EE 8
MicroProfile 2.1 (Oct 2018)
MicroProfile 2.0
mpOpenTracing-1.2
MicroProfile 2.2 (Feb 2019)
Fault Tolerance 2.0
OpenAPI 1.1
OpenTracing 1.3
Rest Client 1.2
11@emilyfhjiang
Health CheckMetrics Open Tracing
JAX-RS JSON-PCDI
Config
Fault
Tolerance
JWT
Propagation
Open API
Rest Client JSON-B
MicroProfile Specifications
12@emilyfhjiang
Theres a good chance youll use REST APIs
13@emilyfhjiang
Eclipse MicroProfile
JAX-RS JSON-PCDIRest Client JSON-B
14@emilyfhjiang
JAX-RS
B
@ApplicationPath("System")
public class SystemApplication extends
Application {}
@Path("properties")
public class PropertiesResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
public JsonObject getProperties() {}
}
15@emilyfhjiang
CDI
BA
public class InventoryManager {
@Inject
private SystemClient systemClient;

}
16@emilyfhjiang
JSON-B & JSON-P
A B
...
@GET
@Produces(MediaType.APPLICATION_JSON)
public InventoryList listContents() {
return manager.list();
}
public class InventoryList {
private List<SystemData> systems;
public InventoryList(List<SystemData> systems) {
this.systems = systems;
}
public List<SystemData> getSystems() {
return systems;
}
}
17@emilyfhjiang
MicroProfile REST Client
BA
@Inject
@RestClient
private SystemClient defaultRestClient;
@Dependent
@RegisterRestClient
@RegisterProvider(UnknownUrlExceptionMapper.class)
@Path("/properties")
public interface SystemClient {
@GET
@Produces(MediaType.APPLICATION_JSON)
public Properties getProperties() throws
UnknownUrlException, ProcessingException;
}
io.openliberty.guides.inventory.client.SystemClient/mp-rest/url=http://localhost:9080/system
18@emilyfhjiang
Handling 100s of Services
1
8
19@emilyfhjiang
Eclipse MicroProfile
JAX-RS JSON-PCDI
Config
Fault
Tolerance
JWT
Propagation
Open API
Rest Client JSON-B
20@emilyfhjiang
MicroProfile OpenAPI
A B
openapi: 3.0.0
info:
title: Inventory App
description: App for storing JVM system properties of various
hosts.
license:
name: Eclipse Public License - v 1.0
url: https://www.eclipse.org/legal/epl-v10.html
version: "1.0"
servers: - url: http://localhost:{port} description: Simple Open
Liberty.
variables:
port:
description: Server HTTP port.
default: "9080"
paths:
/inventory/systems:
get:
summary: List inventory contents.
description: Returns the currently stored host:properties pairs
in the inventory.
operationId: listContents
responses:
200:
description: host:properties pairs stored in the inventory.
content:
application/json:
schema:
$ref: '#/components/schemas/InventoryList
.
http://localhost:9080/openapi/ui
21@emilyfhjiang
MicroProfile JWT
A B
@GET
@RolesAllowed({ "admin", "user" })
@Path("{hostname}")
@Produces(MediaType.APPLICATION_JSON)
public Response getPropertiesForHost(@PathParam("hostname") String hostname,
@Context HttpHeaders httpHeaders) {}
22@emilyfhjiang
MicroProfile Fault Tolerance
A B
@Fallback(fallbackMethod = "fallbackForGet")
public Properties get(String hostname) throws
IOException {
return invUtils.getProperties(hostname);
}
23@emilyfhjiang
A
MicroProfile Config
B
@Inject
@ConfigProperty(name =
"io_openliberty_guides_inventory_inMaintenance")
private Provider<Boolean> inMaintenance;
config_ordinal=100
io_openliberty_guides_inventory_inMaintenance=fals
e
{
"config_ordinal":150,
"io_openliberty_guides_inventory_inMaintenance":true
}
24@emilyfhjiang
Handling 100s of collaborating services requires a strong
operations focus
25@emilyfhjiang
Eclipse MicroProfile
Health Check Metrics Open Tracing
JAX-RS JSON-PCDI
Config
Fault
Tolerance
JWT
Propagation
Open API
Rest Client JSON-B
26@emilyfhjiang
MicroProfile Health
A B
@Health
@ApplicationScoped
public class InventoryResource implements HealthCheck {
...
public boolean isHealthy() {...}
@Override
public HealthCheckResponse call() {
if (!isHealthy()) {
return
HealthCheckResponse.named(InventoryResource).withData().down().build();
}
return
HealthCheckResponse.named(InventoryResource).withData().up().build();
}
}
27@emilyfhjiang
MicroProfile Metrics
A B
@Timed(name = "inventoryPropertiesRequestTime",
absolute = true,
description = "Time needed to get the properties of" +
"a system from the given hostname")
public Properties get(String hostname) {
return invUtils.getProperties(hostname);
}
28@emilyfhjiang
MicroProfile OpenTracing
A B
@Traced(value = true, operationName = "InventoryManager.list")
public InventoryList list() {
return new InventoryList(systems);
}
JAX-RS methods are
automatically
traced by default
29@emilyfhjiang
How to get started?
30@emilyfhjiang
Into the cloud
31@emilyfhjiang
Microservice Deployment
Kubernetes IstioDocker
Health CheckMetrics Open Tracing
JAX-RS JSON-PCDI
Config
Fault
Tolerance
JWT
Propagation
Open API
Rest Client JSON-B
32@emilyfhjiang
MicroProfile Config with Kubernetes
A B
env:
- name: GREETING
valueFrom:
configMapKeyRef:
name: greeting-config
key: message
kubectl create configmap greeting-config --from-literal
message=Greetings...
@Inject
@ConfigProperty(name = "GREETING")
private String greeting;
33@emilyfhjiang
MicroProfile Health with Kubernetes
A B
readinessProbe:
httpGet:
path: /health
port: 9080
initialDelaySeconds: 15
periodSeconds: 5
failureThreshold: 1
34@emilyfhjiang
Upcoming IBM event on modernization
JNation
Europe Application, Platform & Modernization Hursley Summit
9-10th September
Registration: ibm.bz/APMSummit
35@emilyfhjiang
Useful Links
https://microprofile.io
https://openliberty.io/guides
https://docs.docker.com/get-started/
https://kubernetes.io/docs/tutorials/kubernetes-basics/
https://istio.io/docs/setup/kubernetes/quick-start/
https://www.eclipse.org/community/eclipse_newsletter/2018/september/
MicroProfile_istio.php
36@emilyfhjiang 36
Thank you!

More Related Content

The new and smart way to build microservices - Eclipse MicroProfile