SlideShare uma empresa Scribd logo
1 de 17
Baixar para ler offline
MicroProfile-Anwendungen
mit Quarkus - reloaded
Expertenkreis Java, GEDOPLAN GmbH
27.02.2020
Dirk Weil
Dirk Weil
GEDOPLAN GmbH, Bielefeld
GEDOPLAN IT Consulting
Softwareentwicklung, Beratung, Konzepte, Reviews
GEDOPLAN IT Training
Java, JEE, Tools u.v.a.m. in Berlin, Bielefeld, on-site
JEE seit 1998
Speaker und Autor
2gedoplan.deMicroprofile-Anwendungen mit Quarkus - reloaded
Quarkus recap
JEE + MicroProfile + diverse Ergänzungen
Spring-Boot-Alternative
Dev Mode
Hotspot VM und native
https://quarkus.io/
3gedoplan.deMicroprofile-Anwendungen mit Quarkus - reloaded
Quarkus recap
Jakarta EE 8
Jakarta Persistence (aka JPA) mit Hibernate
Autoconfiguration für H2, PostgreSQL, MariaDB, MySQL,
MS SQL, Derby
CDI
Implementierung ARC mit limitiertem Support
Jakarta RESTful Web Services (aka JAX-RS)
RESTeasy mit JsonB-Support
Servlet
Undertow
TX
4gedoplan.deMicroprofile-Anwendungen mit Quarkus - reloaded
Quarkus recap
MicroProfile
Config
jetzt auch application.yaml
Health, Metrics
Rest Client
5gedoplan.de
greeting:
message: Hello
name: world
"%dev":
greeting:
name: developer
application.yaml
@Inject
@ConfigProperty(name = "greeting.name")
String name;
@Path("v2")
@RegisterRestClient
public interface CountryApi {
@GET
@Path("all")
@Produces("application/json")
Collection<Country> getAll();
@Inject
@RestClient
CountryApi countryClient;
Microprofile-Anwendungen mit Quarkus - reloaded
MicroProfile Fault Tolerance
Interceptors für Resilience
@Retry wiederholt Aufruf bei Fehler (=Exception)
@Timeout bricht langsame Aufrufe ab
@Fallback liefert Ersatzwert
6
@Retry(maxRetries = 4)
public int doSomethingWithRetry() {
@Timeout(1000)
public int doSomethingWithTimeout() {
private int return42() {
return 42;
}
@Fallback(fallbackMethod = "return42")
public int doSomethingWithFallback() {
gedoplan.deMicroprofile-Anwendungen mit Quarkus - reloaded
MicroProfile Fault Tolerance
Interceptors für Resilience
@CircuitBreaker unterdrückt Aufrufe bei hoher Fehlerrate
7
@CircuitBreaker(failureRatio = 0.25, requestVolumeThreshold = 10)
public int doSomethingWithCircuitBreaker() {
Demo
quarkus-fault-tolerance
closed open
half-open
zu viele
Fehler
ok
Delay
Fehler
gedoplan.deMicroprofile-Anwendungen mit Quarkus - reloaded
MicroProfile OpenTracing
Aufrufverfolgung
Zero Config für Rest Endpoints und MP Rest Clients
@Traced Interceptor Binding
Jaeger:
Trace Collection + UI
8gedoplan.de
@Traced
public String getPing() {
Demo
quarkus-opentracing
Microprofile-Anwendungen mit Quarkus - reloaded
(MicroProfile Reactive) Messaging
Designierter neuer MP-Bestandteil
9gedoplan.de
@Inject @Channel("demo-channel-1")
Emitter<String> emitter;
…
this.emitter.send(text);
@Incoming("demo-channel-1")
@Outgoing("demo-channel-2")
String process(String text) {
return text.toUpperCase();
@Incoming("demo-channel-2")
void receive(String text) {
this.log.debug("Received " + text);Demo quarkus-amqp
quarkus-kafka
Microprofile-Anwendungen mit Quarkus - reloaded
(MicroProfile Reactive) Messaging
Einbindung von Message Brokern (Artemis, Kafka)
10gedoplan.de
@Inject @Channel("posted-person")
Emitter<Person> emitter;
…
this.emitter.send(person);
mp.messaging.outgoing.posted-person.connector=smallrye-kafka
mp.messaging.outgoing.posted-person.topic=person
mp.messaging.incoming.received-person.connector=smallrye-kafka
mp.messaging.incoming.received-person.topic=person
@Incoming("received-person")
public void onReceive(Person person) {
this.log.debug("onReceive(" + person + ")");
Microprofile-Anwendungen mit Quarkus - reloaded
MicroProfile OpenAPI / Swagger
Endpoint /openapi
(konfigurierbar)
API-Beschreibung kann
mit Annotationen angereichert
werden:
11gedoplan.de
$ curl http://localhost:8080/openapi
---
openapi: 3.0.1
info:
title: Generated API
version: "1.0"
paths:
/person:
get:
summary: Get all persons
responses:
"200":
description: OK
@GET
@Path("{id}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Operation(summary = "Get a person")
@APIResponse(description = "Found person (JSON/XML)")
@APIResponse(responseCode = "404", description = "Person not found")
public Person getById(@PathParam("id") Integer id) {
Microprofile-Anwendungen mit Quarkus - reloaded
MicroProfile OpenAPI / Swagger
Swagger-UI unter /swagger-ui (konfigurierbar)
12gedoplan.de
Demo
quarkus-rest-cdi-jpa
Microprofile-Anwendungen mit Quarkus - reloaded
Native
Graal VM: Erstellung native application target/xyz-runner
Nur tatsächlich genutzter Code
Achtung: Reflection
Build auf Non-Linux im Docker Container
Startzeit im ms-Bereich, Memory consumption im MB-Bereich
13gedoplan.de
$ mvn -Pnative,docker
…
[INFO] docker run -v //c/GEDOPLAN/projects/gedoplan/showcase/quarkus-demo/q
[quarkus-getting-started-runner:22] classlist: 4,939.89 ms
…
[quarkus-getting-started-runner:22] write: 576.45 ms
[quarkus-getting-started-runner:22] [total]: 121,756.96 ms
[INFO] Quarkus augmentation completed in 126125ms
…
[INFO] DOCKER> [docker.gedoplan.de/showcase/quarkus-getting-started:latest]
Microprofile-Anwendungen mit Quarkus - reloaded
MyFaces
https://github.com/apache/myfaces/tree/master/extensions/quarkus
Work in progress!
View Files in src/main/resources/META-INF/resources
Alle Scopes mit Ausnahme von @ConversationScoped
Weitere Libraries:
https://github.com/rmpestano/quarkus-omnifaces
https://github.com/adminfaces/quarkus-admin-starter
14gedoplan.de
Demo
quarkus-myfaces
Microprofile-Anwendungen mit Quarkus - reloaded
Weitere Features
Websockets
JMS
NoSQL
Flyway
Security mit OpenID, Keycloak, JWT RBAC
Spring DI, Web, Data JPA, Security
Scheduling
Mail
Kotlin
…
15gedoplan.deMicroprofile-Anwendungen mit Quarkus - reloaded
Fazit
MicroProfile (+ JEE) = Lightweight Enterprise Java
Quarkus
~ Spring Boot für JEE
kaum Umdenken notwendig für JEE-Entwickler
macht Spaß
native Ausführung möglich
Richtung: Cloud, serverless (?)
frühes Stadium, aber bewährte Komponenten
16gedoplan.deMicroprofile-Anwendungen mit Quarkus - reloaded
More
github.com/GEDOPLAN/quarkus-demo
Demo-Projekte
www.gedoplan-it-training.de
Trainings in Berlin, Bielefeld, inhouse
neu: Microservices mit Quarkus - Grundlagen
neu: Microservices mit Quarkus - Aufbau
www.gedoplan-it-consulting.de
Blog
 dirk.weil@gedoplan.de
@dirkweil
17gedoplan.deMicroprofile-Anwendungen mit Quarkus - reloaded

Mais conteúdo relacionado

Semelhante a Microprofile-Anwendungen mit Quarkus - reloaded

Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...
Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...
Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...gedoplan
 
Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...
Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...
Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...gedoplan
 
Cloud-native and Enterprise Java? Hold my beer!
Cloud-native and Enterprise Java? Hold my beer!Cloud-native and Enterprise Java? Hold my beer!
Cloud-native and Enterprise Java? Hold my beer!OPEN KNOWLEDGE GmbH
 
Service Mesh mit Istio und MicroProfile - eine harmonische Kombination?
Service Mesh mit Istio und MicroProfile - eine harmonische Kombination?Service Mesh mit Istio und MicroProfile - eine harmonische Kombination?
Service Mesh mit Istio und MicroProfile - eine harmonische Kombination?Michael Hofmann
 
Dataservices - Data Processing mit Microservices
Dataservices - Data Processing mit MicroservicesDataservices - Data Processing mit Microservices
Dataservices - Data Processing mit MicroservicesQAware GmbH
 
Cloud Native und Java EE: Freund oder Feind?
Cloud Native und Java EE: Freund oder Feind?Cloud Native und Java EE: Freund oder Feind?
Cloud Native und Java EE: Freund oder Feind?Josef Adersberger
 
Cloud Native & Java EE: Freund oder Feind?
Cloud Native & Java EE: Freund oder Feind?Cloud Native & Java EE: Freund oder Feind?
Cloud Native & Java EE: Freund oder Feind?QAware GmbH
 
Java und Python - Das Beste aus beiden Welten nutzen
Java und Python - Das Beste aus beiden Welten nutzenJava und Python - Das Beste aus beiden Welten nutzen
Java und Python - Das Beste aus beiden Welten nutzenAndreas Schreiber
 
Logical Data Warehouse - SQL mit Oracle DB und Hadoop
Logical Data Warehouse - SQL mit Oracle DB und HadoopLogical Data Warehouse - SQL mit Oracle DB und Hadoop
Logical Data Warehouse - SQL mit Oracle DB und HadoopOPITZ CONSULTING Deutschland
 
Backend-Services mit Rust
Backend-Services mit RustBackend-Services mit Rust
Backend-Services mit RustJens Siebert
 
Enterprise Java Batch mit Spring
Enterprise Java Batch mit SpringEnterprise Java Batch mit Spring
Enterprise Java Batch mit Springdenschu
 
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.Torsten Kleiber
 
Der Application Server ist tot (?) - es lebe Jakarta EE!
Der Application Server ist tot (?) - es lebe Jakarta EE!Der Application Server ist tot (?) - es lebe Jakarta EE!
Der Application Server ist tot (?) - es lebe Jakarta EE!gedoplan
 
Article - JDK 8 im Fokus der Entwickler
Article - JDK 8 im Fokus der EntwicklerArticle - JDK 8 im Fokus der Entwickler
Article - JDK 8 im Fokus der EntwicklerWolfgang Weigend
 
Supersonic Java für die Cloud: Quarkus
Supersonic Java für die Cloud: QuarkusSupersonic Java für die Cloud: Quarkus
Supersonic Java für die Cloud: QuarkusOPEN KNOWLEDGE GmbH
 
Automatisiertes disaster recovery testing mit der oracle cloud
Automatisiertes disaster recovery testing mit der oracle cloudAutomatisiertes disaster recovery testing mit der oracle cloud
Automatisiertes disaster recovery testing mit der oracle cloudTrivadis
 

Semelhante a Microprofile-Anwendungen mit Quarkus - reloaded (20)

Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...
Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...
Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...
 
Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...
Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...
Das Runde muss in das Eckige - Java-Anwendungen für Kubernetes entwickeln und...
 
Cloud-native and Enterprise Java? Hold my beer!
Cloud-native and Enterprise Java? Hold my beer!Cloud-native and Enterprise Java? Hold my beer!
Cloud-native and Enterprise Java? Hold my beer!
 
profil_2017
profil_2017profil_2017
profil_2017
 
Service Mesh mit Istio und MicroProfile - eine harmonische Kombination?
Service Mesh mit Istio und MicroProfile - eine harmonische Kombination?Service Mesh mit Istio und MicroProfile - eine harmonische Kombination?
Service Mesh mit Istio und MicroProfile - eine harmonische Kombination?
 
Dataservices - Data Processing mit Microservices
Dataservices - Data Processing mit MicroservicesDataservices - Data Processing mit Microservices
Dataservices - Data Processing mit Microservices
 
Cloud Native und Java EE: Freund oder Feind?
Cloud Native und Java EE: Freund oder Feind?Cloud Native und Java EE: Freund oder Feind?
Cloud Native und Java EE: Freund oder Feind?
 
Cloud Native & Java EE: Freund oder Feind?
Cloud Native & Java EE: Freund oder Feind?Cloud Native & Java EE: Freund oder Feind?
Cloud Native & Java EE: Freund oder Feind?
 
Java und Python - Das Beste aus beiden Welten nutzen
Java und Python - Das Beste aus beiden Welten nutzenJava und Python - Das Beste aus beiden Welten nutzen
Java und Python - Das Beste aus beiden Welten nutzen
 
Logical Data Warehouse - SQL mit Oracle DB und Hadoop
Logical Data Warehouse - SQL mit Oracle DB und HadoopLogical Data Warehouse - SQL mit Oracle DB und Hadoop
Logical Data Warehouse - SQL mit Oracle DB und Hadoop
 
Backend-Services mit Rust
Backend-Services mit RustBackend-Services mit Rust
Backend-Services mit Rust
 
Enterprise Java Batch mit Spring
Enterprise Java Batch mit SpringEnterprise Java Batch mit Spring
Enterprise Java Batch mit Spring
 
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
Das dreckige Dutzend - ADF Migration nach 12c in der IKB - DOAG 2014.
 
Testing tools
Testing toolsTesting tools
Testing tools
 
Node.js
Node.jsNode.js
Node.js
 
Der Application Server ist tot (?) - es lebe Jakarta EE!
Der Application Server ist tot (?) - es lebe Jakarta EE!Der Application Server ist tot (?) - es lebe Jakarta EE!
Der Application Server ist tot (?) - es lebe Jakarta EE!
 
Article - JDK 8 im Fokus der Entwickler
Article - JDK 8 im Fokus der EntwicklerArticle - JDK 8 im Fokus der Entwickler
Article - JDK 8 im Fokus der Entwickler
 
Supersonic Java für die Cloud: Quarkus
Supersonic Java für die Cloud: QuarkusSupersonic Java für die Cloud: Quarkus
Supersonic Java für die Cloud: Quarkus
 
Automatisiertes disaster recovery testing mit der oracle cloud
Automatisiertes disaster recovery testing mit der oracle cloudAutomatisiertes disaster recovery testing mit der oracle cloud
Automatisiertes disaster recovery testing mit der oracle cloud
 
3. Night of the pack
3. Night of the pack3. Night of the pack
3. Night of the pack
 

Microprofile-Anwendungen mit Quarkus - reloaded

  • 1. MicroProfile-Anwendungen mit Quarkus - reloaded Expertenkreis Java, GEDOPLAN GmbH 27.02.2020 Dirk Weil
  • 2. Dirk Weil GEDOPLAN GmbH, Bielefeld GEDOPLAN IT Consulting Softwareentwicklung, Beratung, Konzepte, Reviews GEDOPLAN IT Training Java, JEE, Tools u.v.a.m. in Berlin, Bielefeld, on-site JEE seit 1998 Speaker und Autor 2gedoplan.deMicroprofile-Anwendungen mit Quarkus - reloaded
  • 3. Quarkus recap JEE + MicroProfile + diverse Ergänzungen Spring-Boot-Alternative Dev Mode Hotspot VM und native https://quarkus.io/ 3gedoplan.deMicroprofile-Anwendungen mit Quarkus - reloaded
  • 4. Quarkus recap Jakarta EE 8 Jakarta Persistence (aka JPA) mit Hibernate Autoconfiguration für H2, PostgreSQL, MariaDB, MySQL, MS SQL, Derby CDI Implementierung ARC mit limitiertem Support Jakarta RESTful Web Services (aka JAX-RS) RESTeasy mit JsonB-Support Servlet Undertow TX 4gedoplan.deMicroprofile-Anwendungen mit Quarkus - reloaded
  • 5. Quarkus recap MicroProfile Config jetzt auch application.yaml Health, Metrics Rest Client 5gedoplan.de greeting: message: Hello name: world "%dev": greeting: name: developer application.yaml @Inject @ConfigProperty(name = "greeting.name") String name; @Path("v2") @RegisterRestClient public interface CountryApi { @GET @Path("all") @Produces("application/json") Collection<Country> getAll(); @Inject @RestClient CountryApi countryClient; Microprofile-Anwendungen mit Quarkus - reloaded
  • 6. MicroProfile Fault Tolerance Interceptors für Resilience @Retry wiederholt Aufruf bei Fehler (=Exception) @Timeout bricht langsame Aufrufe ab @Fallback liefert Ersatzwert 6 @Retry(maxRetries = 4) public int doSomethingWithRetry() { @Timeout(1000) public int doSomethingWithTimeout() { private int return42() { return 42; } @Fallback(fallbackMethod = "return42") public int doSomethingWithFallback() { gedoplan.deMicroprofile-Anwendungen mit Quarkus - reloaded
  • 7. MicroProfile Fault Tolerance Interceptors für Resilience @CircuitBreaker unterdrückt Aufrufe bei hoher Fehlerrate 7 @CircuitBreaker(failureRatio = 0.25, requestVolumeThreshold = 10) public int doSomethingWithCircuitBreaker() { Demo quarkus-fault-tolerance closed open half-open zu viele Fehler ok Delay Fehler gedoplan.deMicroprofile-Anwendungen mit Quarkus - reloaded
  • 8. MicroProfile OpenTracing Aufrufverfolgung Zero Config für Rest Endpoints und MP Rest Clients @Traced Interceptor Binding Jaeger: Trace Collection + UI 8gedoplan.de @Traced public String getPing() { Demo quarkus-opentracing Microprofile-Anwendungen mit Quarkus - reloaded
  • 9. (MicroProfile Reactive) Messaging Designierter neuer MP-Bestandteil 9gedoplan.de @Inject @Channel("demo-channel-1") Emitter<String> emitter; … this.emitter.send(text); @Incoming("demo-channel-1") @Outgoing("demo-channel-2") String process(String text) { return text.toUpperCase(); @Incoming("demo-channel-2") void receive(String text) { this.log.debug("Received " + text);Demo quarkus-amqp quarkus-kafka Microprofile-Anwendungen mit Quarkus - reloaded
  • 10. (MicroProfile Reactive) Messaging Einbindung von Message Brokern (Artemis, Kafka) 10gedoplan.de @Inject @Channel("posted-person") Emitter<Person> emitter; … this.emitter.send(person); mp.messaging.outgoing.posted-person.connector=smallrye-kafka mp.messaging.outgoing.posted-person.topic=person mp.messaging.incoming.received-person.connector=smallrye-kafka mp.messaging.incoming.received-person.topic=person @Incoming("received-person") public void onReceive(Person person) { this.log.debug("onReceive(" + person + ")"); Microprofile-Anwendungen mit Quarkus - reloaded
  • 11. MicroProfile OpenAPI / Swagger Endpoint /openapi (konfigurierbar) API-Beschreibung kann mit Annotationen angereichert werden: 11gedoplan.de $ curl http://localhost:8080/openapi --- openapi: 3.0.1 info: title: Generated API version: "1.0" paths: /person: get: summary: Get all persons responses: "200": description: OK @GET @Path("{id}") @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Operation(summary = "Get a person") @APIResponse(description = "Found person (JSON/XML)") @APIResponse(responseCode = "404", description = "Person not found") public Person getById(@PathParam("id") Integer id) { Microprofile-Anwendungen mit Quarkus - reloaded
  • 12. MicroProfile OpenAPI / Swagger Swagger-UI unter /swagger-ui (konfigurierbar) 12gedoplan.de Demo quarkus-rest-cdi-jpa Microprofile-Anwendungen mit Quarkus - reloaded
  • 13. Native Graal VM: Erstellung native application target/xyz-runner Nur tatsächlich genutzter Code Achtung: Reflection Build auf Non-Linux im Docker Container Startzeit im ms-Bereich, Memory consumption im MB-Bereich 13gedoplan.de $ mvn -Pnative,docker … [INFO] docker run -v //c/GEDOPLAN/projects/gedoplan/showcase/quarkus-demo/q [quarkus-getting-started-runner:22] classlist: 4,939.89 ms … [quarkus-getting-started-runner:22] write: 576.45 ms [quarkus-getting-started-runner:22] [total]: 121,756.96 ms [INFO] Quarkus augmentation completed in 126125ms … [INFO] DOCKER> [docker.gedoplan.de/showcase/quarkus-getting-started:latest] Microprofile-Anwendungen mit Quarkus - reloaded
  • 14. MyFaces https://github.com/apache/myfaces/tree/master/extensions/quarkus Work in progress! View Files in src/main/resources/META-INF/resources Alle Scopes mit Ausnahme von @ConversationScoped Weitere Libraries: https://github.com/rmpestano/quarkus-omnifaces https://github.com/adminfaces/quarkus-admin-starter 14gedoplan.de Demo quarkus-myfaces Microprofile-Anwendungen mit Quarkus - reloaded
  • 15. Weitere Features Websockets JMS NoSQL Flyway Security mit OpenID, Keycloak, JWT RBAC Spring DI, Web, Data JPA, Security Scheduling Mail Kotlin … 15gedoplan.deMicroprofile-Anwendungen mit Quarkus - reloaded
  • 16. Fazit MicroProfile (+ JEE) = Lightweight Enterprise Java Quarkus ~ Spring Boot für JEE kaum Umdenken notwendig für JEE-Entwickler macht Spaß native Ausführung möglich Richtung: Cloud, serverless (?) frühes Stadium, aber bewährte Komponenten 16gedoplan.deMicroprofile-Anwendungen mit Quarkus - reloaded
  • 17. More github.com/GEDOPLAN/quarkus-demo Demo-Projekte www.gedoplan-it-training.de Trainings in Berlin, Bielefeld, inhouse neu: Microservices mit Quarkus - Grundlagen neu: Microservices mit Quarkus - Aufbau www.gedoplan-it-consulting.de Blog  dirk.weil@gedoplan.de @dirkweil 17gedoplan.deMicroprofile-Anwendungen mit Quarkus - reloaded