SlideShare a Scribd company logo
1 of 60
Download to read offline
@radcortez | #TomEE
Lightweight Enterprise Java
with
MicroProfile
Roberto Cortez
@radcortez
@radcortez | #TomEE
Who am I?
Passionate Developer, Blogger, Youtuber, Speaker, JUG Leader, Java
Champion
twi@er:
@radcortez
blog:
h@p://www.radcortez.com
youtube:
h@p://youtube.com/radcortez
mail:
radcortez@yahoo.com
@radcortez | #TomEE
Questions?
Ask as soon as you have them!
@radcortez | #TomEE
Agenda
• Microservices!
• What is MicroProfile?
• Specs Overview
• Demos
• MicroProfile Future
Microservices Anyone?
@radcortez | #TomEE
Microservices
• Have you heard about Microservices?
• How big is a micro?
• Who develops Microservices?
• Who deploys Microservices?
• Who likes Microservices?
@radcortez | #TomEE
What do others think?
@radcortez | #TomEE
What do others think?
@radcortez | #TomEE
What do others think?
@radcortez | #TomEE
What do others think?
@radcortez | #TomEE
What do others think?
@radcortez | #TomEE
What do others think?
@radcortez | #TomEE
Why Microservices?
• Deliver new features quicker
• Smaller, agile teams
• Scale services independently
• Cloud
@radcortez | #TomEE
What is MicroProfile?
• http://microprofile.io/
• Enterprise Java for Microservices
• Open Source (Eclipse)
@radcortez | #TomEE
What is MicroProfile?
• Initial version 1.0 with CDI, JAX-RS, JSON-P
• Application portability across runtimes
@radcortez | #TomEE
What is MicroProfile?
• Currently at version 1.3
• Configuration, Fault Tolerance, JWT Propagation,
Health Check, Metrics, Open Tracing, Open API and
REST Client
• A version 2.0 is planned
@radcortez | #TomEE
Who is involved in MicroProfile?
@radcortez | #TomEE
Why MicroProfile?
@radcortez | #TomEE
0
10
20
30
40
EE 5 Specs (2006) EE 6 Specs (2009) EE 7 Specs (2013) EE 8 Specs (2017)
39
37
30
24
Why MicroProfile?
• A set of “standards” were required to offer guidance in
building MicroServices in Java
• These need to evolve very quickly to adjust to the fast
moving MicroServices world
@radcortez | #TomEE
MicroProfile Implementations
• Apache TomEE
• WebSphere Liberty
• WildFly Swarm
• Payara Micro
• KumuluzEE
@radcortez | #TomEE
What is TomEE?
• Tomcat + Java EE = TomEE
• Built within the OpenEJB community to offer a lightweight
alternative with Tomcat being the top dog.
• TomEE 7 is a MicroProfile implementation, including JAX-RS, CDI,
JSON-P and other specifications from Java EE.
• Currently working on MicroProfile 1.3.
@radcortez | #TomEE
My first MicroProfile App
@radcortez | #TomEE
CDI
• Contexts and Dependency Injection
• Bean Lifecycle and Typesafe Injection
• Producers
• Interceptors
• Observers
@radcortez | #TomEE
JAX-RS
• RESTful Web Services
• Annotation based
• HTTP Centric
@radcortez | #TomEE
JSON-P
• Parse, Generate Transform and Query JSON
• Streaming API
• Object Model API
@radcortez | #TomEE
Putting it all together
@ApplicationScoped

@Path("books")

public class BookResource {

@Inject

private BookBean bookBean;



@GET

@Path("{id}")

public Response find(@PathParam("id") final Long id) {

final Book book = bookBean.find(id);

final JsonObjectBuilder builder = Json.createObjectBuilder();

builder.add("id", book.getId())

.add("name", book.getTitle());

return Response.ok(builder.build().toString()).build();

}

}
@radcortez | #TomEE
Show me the code!
@radcortez | #TomEE
https://github.com/radcortez/microprofile-samples
Deploy
• Raspberry PI running Hypriot OS.
• Package everything with Docker
• Local Docker Registry
• Push Docker Images with Ansible
@radcortez | #TomEE
Raspberry PI
• Raspberry V3
• HypriotOS is a minimal Debian dist
• Optimized to run Docker on a Raspberry PI
@radcortez | #TomEE
Docker
• Use Maven Fabric8 Plugin
• Docker Hub too slow
• Use a Local Docker Registry
• Speed up Deployment
@radcortez | #TomEE
Ansible
• Automate Tasks
• Ping PIs
• Deploy Docker Images, Start, Stop
• Ansible Playbooks
• List of tasks to perform
@radcortez | #TomEE
Evolving your MicroProfile App
@radcortez | #TomEE
Configuration
• Applications need configuration based on their running
environment
• It must be possible to change configuration without
repacking the application
• Based on DeltaSpike Config, Apache Tamaya and Sabot
@radcortez | #TomEE
Configuration
• META-INF/microprofile-config.properties
• Environment properties
• System properties
• Pluggable to allow custom config sources and providers
through the ServiceLoader mechanism
@radcortez | #TomEE
public class MoviesRest {
@Inject
@ConfigProperty(name="connection.url")
private String setting;
@Inject
@ConfigProperty(name="connection.port")
private Optional<Integer> port;
public void execute() {
Config config = ConfigProvider.getConfig();
String url = config.getValue("connection.url", String.class);
}
}
@radcortez | #TomEE
Metrics
• Monitor essential System Parameters
• Ensure reliable operation of software
• Monitoring endpoints to collect data
@radcortez | #TomEE
Metrics
• Accessible via REST interface
• /metrics/base for MP compliant servers
• /metrics/application for Application specific Metrics
• /metrics/vendor for Server specific metrics
• OPTIONS provides metadata, such as Unit of measure
@radcortez | #TomEE
{
"thread.count" : 33,
"thread.max.count" : 47,
"memory.maxHeap" : 3817863211,
"memory.usedHeap" : 16859081,
"memory.committedHeap" : 64703546
}
GET /metrics/base
@radcortez | #TomEE
{
"fooVal": {
"unit": "milliseconds",
"type": "gauge",
"description": "The average duration of foo
requests during last 5 minutes",
"displayName": "Duration of foo",
"tags": "app=webshop"
},
"barVal": {
"unit": "megabytes",
"type": "gauge",
"tags": "component=backend,app=webshop"
}
}
OPTIONS /metrics/base
@radcortez | #TomEE
Healthchecks
• Probe the state of a computer node
• Primary target cloud infrastructure
• Automated processes to maintain the state of nodes
@radcortez | #TomEE
Healthchecks
• Simple API to specify health status
• /health JAX-RS endpoint reporting server health
• Response status indicates if the health check passed
• Payload can include more detail
@radcortez | #TomEE
Healthchecks
@Health
@ApplicationScoped
public class CheckDiskSpace implements HealthCheck {
public HealthCheckResponse call() {
}
}
@radcortez | #TomEE
@radcortez | #TomEE
{
"outcome": "UP",
"checks": [{
"name": "diskspace",
"state": "UP",
"data": {
"key": "freebytes",
"freebytes": "126000000000"
}
}]
}
GET /health
Fault Tolerance
• Different strategies to guide the execution and result
of some logic
• TimeOut, RetryPolicy, Fallback, Bulkhead and Circuit
Breaker
• Inspired by Hystrix and Failsafe
@radcortez | #TomEE
@CircuitBreaker
@Fallback(NumberFallbackHandler.class)
public String getNumber() {
final Response response = numberApi.request().get();
if (OK.getStatusCode() == response.getStatus()) {
return response.readEntity(String.class);
}
throw new WebApplicationException(INTERNAL_SERVER_ERROR);
}
public class NumberFallbackHandler implements FallbackHandler<String> {
@Override
public String handle(final ExecutionContext context) {
return "FALLBACK_NUMBER";
}
}
@radcortez | #TomEE
JWT Propagation
• Security Tokens
• Most common: OAuth2, OpenID Connect JWT
• Lightweight way to propagate identities across
different services
@radcortez | #TomEE
OpenTracing
• Trace the flow of a request across services
• OpenTracing is a distributed tracing standard for
applications
• Java Binding to OpenTracing Implementation
@radcortez | #TomEE
@Trace
@GET
@Path(“/findByStatus")
public Response findPetsByStatus() { }
@Inject
private Tracer tracer;
tracer.activeSpan().setTag(…);
tracer.activeSpan().log(...);
tracer.activeSpan().setBaggage(...);
@radcortez | #TomEE
Open API
• Java API for the OpenAPI v3 specification
• OpenAPI v3 is based on Swagger v2
• Annotations should be similar
@radcortez | #TomEE
@GET
@Path(“/findByStatus")
@Operation(
summary = "Finds Pets by status",
description = "Multiple status values can be
provided with comma separated strings")
public Response findPetsByStatus() { }
GET /openapi
/pet/findByStatus:
get:
summary: Finds Pets by status
description: Multiple status values can be provided with comma separated
strings
operationId: findPetsByStatus
@radcortez | #TomEE
REST Client
• Microservices typically talk REST to other services
• Several JAX-RS implementations already support
interface definition
• Consistent and easy to reuse
@radcortez | #TomEE
REST Client
• Type safe REST Service over HTTP
• Extends JAX-RS 2.0 API’s
• More natural code style
• Similar to Feign
@radcortez | #TomEE
@RegisterRestClient
public interface MyServiceClient {
@GET
@Path("/greet")
Response greet();
}
@ApplicationScoped
public class MyService {
@Inject
@RestClient
private MyServiceClient client;
}
@radcortez | #TomEE
Future
@radcortez | #TomEE
MicroProfile Roadmap
• MicroProfile 1.4
• Improve Developer Documentation
• Incremental specification updates
@radcortez | #TomEE
MicroProfile Roadmap
• MicroProfile 1.4
• Improve Developer Documentation
• Incremental specification updates
@radcortez | #TomEE
MicroProfile Roadmap
• MicroProfile 2.0
• Update to latest shared Java EE (EE4J) specifications
• CDI 2.0, JAX-RS 2.1, JSON-P 1.1
• Add JSON-B 1.0
@radcortez | #TomEE
Get Involved
• https://groups.google.com/forum/#!forum/
microprofile
@radcortez | #TomEE
Resources
• http://microprofile.io/
• http://tomee.apache.org
• https://github.com/radcortez/microprofile-samples
@radcortez | #TomEE
Thank you for attending!
@radcortez | #TomEE
https://tribestream.io/join-beta-devnexus/
QA

More Related Content

What's hot

XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
Balazs Bucsay
 
Trick or XFLTReaT a.k.a. Tunnel All The Things
Trick or XFLTReaT a.k.a. Tunnel All The ThingsTrick or XFLTReaT a.k.a. Tunnel All The Things
Trick or XFLTReaT a.k.a. Tunnel All The Things
Balazs Bucsay
 

What's hot (20)

Jenkins2 - Coding Continuous Delivery Pipelines
Jenkins2 - Coding Continuous Delivery PipelinesJenkins2 - Coding Continuous Delivery Pipelines
Jenkins2 - Coding Continuous Delivery Pipelines
 
IIT-RTC 2017 Qt WebRTC Tutorial (Qt Janus Client)
IIT-RTC 2017 Qt WebRTC Tutorial (Qt Janus Client)IIT-RTC 2017 Qt WebRTC Tutorial (Qt Janus Client)
IIT-RTC 2017 Qt WebRTC Tutorial (Qt Janus Client)
 
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
XFLTReaT: a new dimension in tunnelling (BruCON 0x09 2017)
 
Trick or XFLTReaT a.k.a. Tunnel All The Things
Trick or XFLTReaT a.k.a. Tunnel All The ThingsTrick or XFLTReaT a.k.a. Tunnel All The Things
Trick or XFLTReaT a.k.a. Tunnel All The Things
 
Oliot epcis at a glance
Oliot epcis at a glanceOliot epcis at a glance
Oliot epcis at a glance
 
Monitoring at Cloud Scale
Monitoring at Cloud ScaleMonitoring at Cloud Scale
Monitoring at Cloud Scale
 
Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)
 
Your first patch to open stack
Your first patch to open stackYour first patch to open stack
Your first patch to open stack
 
TDC2018SP | Trilha Java - Computacao [Concorrente | Paralela | Distribuida] e...
TDC2018SP | Trilha Java - Computacao [Concorrente | Paralela | Distribuida] e...TDC2018SP | Trilha Java - Computacao [Concorrente | Paralela | Distribuida] e...
TDC2018SP | Trilha Java - Computacao [Concorrente | Paralela | Distribuida] e...
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
From ZERO to REST in an hour
From ZERO to REST in an hour From ZERO to REST in an hour
From ZERO to REST in an hour
 
Building XWiki
Building XWikiBuilding XWiki
Building XWiki
 
Reactive Programming in Java and Spring Framework 5
Reactive Programming in Java and Spring Framework 5Reactive Programming in Java and Spring Framework 5
Reactive Programming in Java and Spring Framework 5
 
Introduction to github using Egit
Introduction to github using EgitIntroduction to github using Egit
Introduction to github using Egit
 
DSR Testing (Part 1)
DSR Testing (Part 1)DSR Testing (Part 1)
DSR Testing (Part 1)
 
Approaches to Building Media Streaming Applications
Approaches to Building Media Streaming ApplicationsApproaches to Building Media Streaming Applications
Approaches to Building Media Streaming Applications
 
Git training v10
Git training v10Git training v10
Git training v10
 
Postgresql 9.0 HA at RMLL 2012
Postgresql 9.0 HA at RMLL 2012Postgresql 9.0 HA at RMLL 2012
Postgresql 9.0 HA at RMLL 2012
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microservice
 
WebRTC Browsers n Stacks Implementation differences
WebRTC Browsers n Stacks Implementation differencesWebRTC Browsers n Stacks Implementation differences
WebRTC Browsers n Stacks Implementation differences
 

Similar to Lightweight Enterprise Java With Microprofile

Similar to Lightweight Enterprise Java With Microprofile (20)

GraalVM and MicroProfile - A Polyglot Microservices Solution
GraalVM and MicroProfile - A Polyglot Microservices SolutionGraalVM and MicroProfile - A Polyglot Microservices Solution
GraalVM and MicroProfile - A Polyglot Microservices Solution
 
2018 (codeone) Graal VM and MicroProfile a polyglot microservices solution [d...
2018 (codeone) Graal VM and MicroProfile a polyglot microservices solution [d...2018 (codeone) Graal VM and MicroProfile a polyglot microservices solution [d...
2018 (codeone) Graal VM and MicroProfile a polyglot microservices solution [d...
 
MicroProfile: A Quest for a Lightweight and Modern Enterprise Java Platform
MicroProfile: A Quest for a Lightweight and Modern Enterprise Java PlatformMicroProfile: A Quest for a Lightweight and Modern Enterprise Java Platform
MicroProfile: A Quest for a Lightweight and Modern Enterprise Java Platform
 
Paving the way with Jakarta EE and apache TomEE at cloudconferenceday
Paving the way with Jakarta EE and apache TomEE at cloudconferencedayPaving the way with Jakarta EE and apache TomEE at cloudconferenceday
Paving the way with Jakarta EE and apache TomEE at cloudconferenceday
 
Pavimentando el Camino con Jakarta EE 9 y Apache TomEE 9.0.0
Pavimentando el Camino con Jakarta EE 9 y Apache TomEE 9.0.0Pavimentando el Camino con Jakarta EE 9 y Apache TomEE 9.0.0
Pavimentando el Camino con Jakarta EE 9 y Apache TomEE 9.0.0
 
Pavimentando el camino con Jakarta EE 9 y Apache TomEE
Pavimentando el camino con Jakarta EE 9 y Apache TomEE Pavimentando el camino con Jakarta EE 9 y Apache TomEE
Pavimentando el camino con Jakarta EE 9 y Apache TomEE
 
OSDC 2015: Tudor Golubenco | Application Performance Management with Packetbe...
OSDC 2015: Tudor Golubenco | Application Performance Management with Packetbe...OSDC 2015: Tudor Golubenco | Application Performance Management with Packetbe...
OSDC 2015: Tudor Golubenco | Application Performance Management with Packetbe...
 
Collector Web Services
Collector Web ServicesCollector Web Services
Collector Web Services
 
Stackato v2
Stackato v2Stackato v2
Stackato v2
 
Monitoring in a fast-changing world with Prometheus
Monitoring in a fast-changing world with PrometheusMonitoring in a fast-changing world with Prometheus
Monitoring in a fast-changing world with Prometheus
 
CATzure Azure Functions
CATzure Azure FunctionsCATzure Azure Functions
CATzure Azure Functions
 
How to Build Single Page HTML5 Apps that Scale
How to Build Single Page HTML5 Apps that ScaleHow to Build Single Page HTML5 Apps that Scale
How to Build Single Page HTML5 Apps that Scale
 
Api fundamentals
Api fundamentalsApi fundamentals
Api fundamentals
 
Building Awesome APIs with Lumen
Building Awesome APIs with LumenBuilding Awesome APIs with Lumen
Building Awesome APIs with Lumen
 
Api FUNdamentals #MHA2017
Api FUNdamentals #MHA2017Api FUNdamentals #MHA2017
Api FUNdamentals #MHA2017
 
Stackato v3
Stackato v3Stackato v3
Stackato v3
 
Stackato v4
Stackato v4Stackato v4
Stackato v4
 
Ratpack Web Framework
Ratpack Web FrameworkRatpack Web Framework
Ratpack Web Framework
 
Observability beyond logging for Java Microservices
Observability beyond logging for Java MicroservicesObservability beyond logging for Java Microservices
Observability beyond logging for Java Microservices
 
Kubernetes and AWS Lambda can play nicely together
Kubernetes and AWS Lambda can play nicely togetherKubernetes and AWS Lambda can play nicely together
Kubernetes and AWS Lambda can play nicely together
 

More from Roberto Cortez

Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7
Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7
Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7
Roberto Cortez
 
Coimbra JUG - 1º Encontro - As novidades do Java 8
Coimbra JUG - 1º Encontro - As novidades do Java 8Coimbra JUG - 1º Encontro - As novidades do Java 8
Coimbra JUG - 1º Encontro - As novidades do Java 8
Roberto Cortez
 

More from Roberto Cortez (13)

Chasing the RESTful Trinity - Client CLI and Documentation
Chasing the RESTful Trinity - Client CLI and DocumentationChasing the RESTful Trinity - Client CLI and Documentation
Chasing the RESTful Trinity - Client CLI and Documentation
 
Baking a Microservice PI(e)
Baking a Microservice PI(e)Baking a Microservice PI(e)
Baking a Microservice PI(e)
 
Deconstructing and Evolving REST Security
Deconstructing and Evolving REST SecurityDeconstructing and Evolving REST Security
Deconstructing and Evolving REST Security
 
Java EE 7 meets Java 8
Java EE 7 meets Java 8Java EE 7 meets Java 8
Java EE 7 meets Java 8
 
Maven - Taming the Beast
Maven - Taming the BeastMaven - Taming the Beast
Maven - Taming the Beast
 
The First Contact with Java EE 7
The First Contact with Java EE 7The First Contact with Java EE 7
The First Contact with Java EE 7
 
Migration tales from java ee 5 to 7
Migration tales from java ee 5 to 7Migration tales from java ee 5 to 7
Migration tales from java ee 5 to 7
 
Development Horror Stories
Development Horror StoriesDevelopment Horror Stories
Development Horror Stories
 
The 5 People in your Organization that grow Legacy Code
The 5 People in your Organization that grow Legacy CodeThe 5 People in your Organization that grow Legacy Code
The 5 People in your Organization that grow Legacy Code
 
Java EE 7 Batch processing in the Real World
Java EE 7 Batch processing in the Real WorldJava EE 7 Batch processing in the Real World
Java EE 7 Batch processing in the Real World
 
Geecon 2014 - Five Ways to Not Suck at Being a Java Freelancer
Geecon 2014 - Five Ways to Not Suck at Being a Java FreelancerGeecon 2014 - Five Ways to Not Suck at Being a Java Freelancer
Geecon 2014 - Five Ways to Not Suck at Being a Java Freelancer
 
Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7
Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7
Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7
 
Coimbra JUG - 1º Encontro - As novidades do Java 8
Coimbra JUG - 1º Encontro - As novidades do Java 8Coimbra JUG - 1º Encontro - As novidades do Java 8
Coimbra JUG - 1º Encontro - As novidades do Java 8
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

Lightweight Enterprise Java With Microprofile

  • 1. @radcortez | #TomEE Lightweight Enterprise Java with MicroProfile Roberto Cortez @radcortez
  • 2. @radcortez | #TomEE Who am I? Passionate Developer, Blogger, Youtuber, Speaker, JUG Leader, Java Champion twi@er: @radcortez blog: h@p://www.radcortez.com youtube: h@p://youtube.com/radcortez mail: radcortez@yahoo.com
  • 3. @radcortez | #TomEE Questions? Ask as soon as you have them!
  • 4. @radcortez | #TomEE Agenda • Microservices! • What is MicroProfile? • Specs Overview • Demos • MicroProfile Future
  • 6. Microservices • Have you heard about Microservices? • How big is a micro? • Who develops Microservices? • Who deploys Microservices? • Who likes Microservices? @radcortez | #TomEE
  • 7. What do others think? @radcortez | #TomEE
  • 8. What do others think? @radcortez | #TomEE
  • 9. What do others think? @radcortez | #TomEE
  • 10. What do others think? @radcortez | #TomEE
  • 11. What do others think? @radcortez | #TomEE
  • 12. What do others think? @radcortez | #TomEE
  • 13. Why Microservices? • Deliver new features quicker • Smaller, agile teams • Scale services independently • Cloud @radcortez | #TomEE
  • 14. What is MicroProfile? • http://microprofile.io/ • Enterprise Java for Microservices • Open Source (Eclipse) @radcortez | #TomEE
  • 15. What is MicroProfile? • Initial version 1.0 with CDI, JAX-RS, JSON-P • Application portability across runtimes @radcortez | #TomEE
  • 16. What is MicroProfile? • Currently at version 1.3 • Configuration, Fault Tolerance, JWT Propagation, Health Check, Metrics, Open Tracing, Open API and REST Client • A version 2.0 is planned @radcortez | #TomEE
  • 17. Who is involved in MicroProfile? @radcortez | #TomEE
  • 18. Why MicroProfile? @radcortez | #TomEE 0 10 20 30 40 EE 5 Specs (2006) EE 6 Specs (2009) EE 7 Specs (2013) EE 8 Specs (2017) 39 37 30 24
  • 19. Why MicroProfile? • A set of “standards” were required to offer guidance in building MicroServices in Java • These need to evolve very quickly to adjust to the fast moving MicroServices world @radcortez | #TomEE
  • 20. MicroProfile Implementations • Apache TomEE • WebSphere Liberty • WildFly Swarm • Payara Micro • KumuluzEE @radcortez | #TomEE
  • 21. What is TomEE? • Tomcat + Java EE = TomEE • Built within the OpenEJB community to offer a lightweight alternative with Tomcat being the top dog. • TomEE 7 is a MicroProfile implementation, including JAX-RS, CDI, JSON-P and other specifications from Java EE. • Currently working on MicroProfile 1.3. @radcortez | #TomEE
  • 22. My first MicroProfile App @radcortez | #TomEE
  • 23. CDI • Contexts and Dependency Injection • Bean Lifecycle and Typesafe Injection • Producers • Interceptors • Observers @radcortez | #TomEE
  • 24. JAX-RS • RESTful Web Services • Annotation based • HTTP Centric @radcortez | #TomEE
  • 25. JSON-P • Parse, Generate Transform and Query JSON • Streaming API • Object Model API @radcortez | #TomEE
  • 26. Putting it all together @ApplicationScoped
 @Path("books")
 public class BookResource {
 @Inject
 private BookBean bookBean;
 
 @GET
 @Path("{id}")
 public Response find(@PathParam("id") final Long id) {
 final Book book = bookBean.find(id);
 final JsonObjectBuilder builder = Json.createObjectBuilder();
 builder.add("id", book.getId())
 .add("name", book.getTitle());
 return Response.ok(builder.build().toString()).build();
 }
 } @radcortez | #TomEE
  • 27. Show me the code! @radcortez | #TomEE https://github.com/radcortez/microprofile-samples
  • 28. Deploy • Raspberry PI running Hypriot OS. • Package everything with Docker • Local Docker Registry • Push Docker Images with Ansible @radcortez | #TomEE
  • 29. Raspberry PI • Raspberry V3 • HypriotOS is a minimal Debian dist • Optimized to run Docker on a Raspberry PI @radcortez | #TomEE
  • 30. Docker • Use Maven Fabric8 Plugin • Docker Hub too slow • Use a Local Docker Registry • Speed up Deployment @radcortez | #TomEE
  • 31. Ansible • Automate Tasks • Ping PIs • Deploy Docker Images, Start, Stop • Ansible Playbooks • List of tasks to perform @radcortez | #TomEE
  • 32. Evolving your MicroProfile App @radcortez | #TomEE
  • 33. Configuration • Applications need configuration based on their running environment • It must be possible to change configuration without repacking the application • Based on DeltaSpike Config, Apache Tamaya and Sabot @radcortez | #TomEE
  • 34. Configuration • META-INF/microprofile-config.properties • Environment properties • System properties • Pluggable to allow custom config sources and providers through the ServiceLoader mechanism @radcortez | #TomEE
  • 35. public class MoviesRest { @Inject @ConfigProperty(name="connection.url") private String setting; @Inject @ConfigProperty(name="connection.port") private Optional<Integer> port; public void execute() { Config config = ConfigProvider.getConfig(); String url = config.getValue("connection.url", String.class); } } @radcortez | #TomEE
  • 36. Metrics • Monitor essential System Parameters • Ensure reliable operation of software • Monitoring endpoints to collect data @radcortez | #TomEE
  • 37. Metrics • Accessible via REST interface • /metrics/base for MP compliant servers • /metrics/application for Application specific Metrics • /metrics/vendor for Server specific metrics • OPTIONS provides metadata, such as Unit of measure @radcortez | #TomEE
  • 38. { "thread.count" : 33, "thread.max.count" : 47, "memory.maxHeap" : 3817863211, "memory.usedHeap" : 16859081, "memory.committedHeap" : 64703546 } GET /metrics/base @radcortez | #TomEE
  • 39. { "fooVal": { "unit": "milliseconds", "type": "gauge", "description": "The average duration of foo requests during last 5 minutes", "displayName": "Duration of foo", "tags": "app=webshop" }, "barVal": { "unit": "megabytes", "type": "gauge", "tags": "component=backend,app=webshop" } } OPTIONS /metrics/base @radcortez | #TomEE
  • 40. Healthchecks • Probe the state of a computer node • Primary target cloud infrastructure • Automated processes to maintain the state of nodes @radcortez | #TomEE
  • 41. Healthchecks • Simple API to specify health status • /health JAX-RS endpoint reporting server health • Response status indicates if the health check passed • Payload can include more detail @radcortez | #TomEE
  • 42. Healthchecks @Health @ApplicationScoped public class CheckDiskSpace implements HealthCheck { public HealthCheckResponse call() { } } @radcortez | #TomEE
  • 43. @radcortez | #TomEE { "outcome": "UP", "checks": [{ "name": "diskspace", "state": "UP", "data": { "key": "freebytes", "freebytes": "126000000000" } }] } GET /health
  • 44. Fault Tolerance • Different strategies to guide the execution and result of some logic • TimeOut, RetryPolicy, Fallback, Bulkhead and Circuit Breaker • Inspired by Hystrix and Failsafe @radcortez | #TomEE
  • 45. @CircuitBreaker @Fallback(NumberFallbackHandler.class) public String getNumber() { final Response response = numberApi.request().get(); if (OK.getStatusCode() == response.getStatus()) { return response.readEntity(String.class); } throw new WebApplicationException(INTERNAL_SERVER_ERROR); } public class NumberFallbackHandler implements FallbackHandler<String> { @Override public String handle(final ExecutionContext context) { return "FALLBACK_NUMBER"; } } @radcortez | #TomEE
  • 46. JWT Propagation • Security Tokens • Most common: OAuth2, OpenID Connect JWT • Lightweight way to propagate identities across different services @radcortez | #TomEE
  • 47. OpenTracing • Trace the flow of a request across services • OpenTracing is a distributed tracing standard for applications • Java Binding to OpenTracing Implementation @radcortez | #TomEE
  • 48. @Trace @GET @Path(“/findByStatus") public Response findPetsByStatus() { } @Inject private Tracer tracer; tracer.activeSpan().setTag(…); tracer.activeSpan().log(...); tracer.activeSpan().setBaggage(...); @radcortez | #TomEE
  • 49. Open API • Java API for the OpenAPI v3 specification • OpenAPI v3 is based on Swagger v2 • Annotations should be similar @radcortez | #TomEE
  • 50. @GET @Path(“/findByStatus") @Operation( summary = "Finds Pets by status", description = "Multiple status values can be provided with comma separated strings") public Response findPetsByStatus() { } GET /openapi /pet/findByStatus: get: summary: Finds Pets by status description: Multiple status values can be provided with comma separated strings operationId: findPetsByStatus @radcortez | #TomEE
  • 51. REST Client • Microservices typically talk REST to other services • Several JAX-RS implementations already support interface definition • Consistent and easy to reuse @radcortez | #TomEE
  • 52. REST Client • Type safe REST Service over HTTP • Extends JAX-RS 2.0 API’s • More natural code style • Similar to Feign @radcortez | #TomEE
  • 53. @RegisterRestClient public interface MyServiceClient { @GET @Path("/greet") Response greet(); } @ApplicationScoped public class MyService { @Inject @RestClient private MyServiceClient client; } @radcortez | #TomEE
  • 55. MicroProfile Roadmap • MicroProfile 1.4 • Improve Developer Documentation • Incremental specification updates @radcortez | #TomEE
  • 56. MicroProfile Roadmap • MicroProfile 1.4 • Improve Developer Documentation • Incremental specification updates @radcortez | #TomEE
  • 57. MicroProfile Roadmap • MicroProfile 2.0 • Update to latest shared Java EE (EE4J) specifications • CDI 2.0, JAX-RS 2.1, JSON-P 1.1 • Add JSON-B 1.0 @radcortez | #TomEE
  • 59. Resources • http://microprofile.io/ • http://tomee.apache.org • https://github.com/radcortez/microprofile-samples @radcortez | #TomEE
  • 60. Thank you for attending! @radcortez | #TomEE https://tribestream.io/join-beta-devnexus/ QA