Slide 1

Slide 1 text

1 Erik-Berndt Scheper 2020 - A space odyssey with Micronaut and Quarkus

Slide 2

Slide 2 text

Agenda Introduction A brief history of Java Space Getting started Feature comparison Developer friendly? Production ready? High scores Wrap-up 2 https://pixabay.com/p-683065/

Slide 3

Slide 3 text

Introduction - Let’s meet • Java Architect & Codesmith @ Ordina JTech ‣ I ❤ JAVA conferences! • Contracted by Ministry of Justice and Security • Passion for ‣ Big Data technologies ‣ Machine learning 3

Slide 4

Slide 4 text

https://nl.wikipedia.org/wiki/Bartje#/media/File:Standbeeld-bartje.jpg Introduction - My home town 4 https://www.ttcircuit.com/wp-content/uploads/2018/11/0P9A1643AA-1024x683.jpg

Slide 5

Slide 5 text

Agenda Introduction A brief history of Java Space Getting started Feature comparison Developer friendly? Production ready? High scores Wrap-up 5 https://pixabay.com/p-683065/

Slide 6

Slide 6 text

https://en.wikipedia.org/wiki/File:LH_95.jpg A brief history of Java Space … 6

Slide 7

Slide 7 text

https://pixabay.com/nl/photos/spook-meisje-gotisch-donker-goth-2935132/ 1992 - J2EE 1.2 7 1. Deployment descriptors 2. EJB 2.x 3. Java Server Pages (and other horrors … )

Slide 8

Slide 8 text

https://pixabay.com/nl/photos/krokus-bloem-lente-het-voorjaar-2139395/ 2006 - The EJB era ends 8

Slide 9

Slide 9 text

https://sdtimes.com/wp-content/uploads/2018/03/spring-boot.png Containerless services in 201 9 2 3 4 5 …

Slide 10

Slide 10 text

… but when you least expect it … 10 GAME OVER ?!?

Slide 11

Slide 11 text

Micronaut 1. Developed by creators from Grails 2. Goals ‣ Provide all the necessary tools to build full featured microservice applications ‣ Avoid downsides of Spring, Spring Boot, Grails 3. Features ‣ Fast startup, reduced memory ‣ Minimal use of proxies & reflection 11

Slide 12

Slide 12 text

Quarkus 1. Developed by RedHat 2. Goals ‣ Container-first and cloud-native ‣ Imperative and reactive ‣ Optimized for developer joy 3. Features ‣ Extension system to integrate frameworks ‣ Minimal use of proxies & reflection 12

Slide 13

Slide 13 text

https://www.nasa.gov/mission_pages/spitzer/multimedia/20080528.html 13 LET’S CHECK THIS OUT !

Slide 14

Slide 14 text

14

Slide 15

Slide 15 text

Agenda Introduction A Brief history of Java Space Getting started Feature comparison Developer friendly? Production ready? High scores Wrap-up 15 https://pixabay.com/p-683065/

Slide 16

Slide 16 text

https://pixabay.com/photos/rocket-launch-rocket-take-off-nasa-67643/ Getting started 16

Slide 17

Slide 17 text

Getting started – Spring Boot • Spring Initializr project ‣ Open https://start.spring.io ‣ Enter name, features, etc. ‣ Download resulting zip-file • Or use the Spring-boot CLI … 17 $ brew tap pivotal/tap $ brew install springboot $ spring init -d=web,jpa \ -g com.github.fbascheper.odyssey \ -n spring-demo

Slide 18

Slide 18 text

$ brew install micronaut $ setjdk8 # use JDK 8 to prevent warnings $ mn profile-info base # lists available features $ mn create-app com.github.fbascheper.odyssey.mn-demo \ --features=junit,jdbc-hikari,hibernate-jpa,graal-native-image \ --build=maven # default is GRADLE $ cd mn-demo $ ./mvnw verify Getting started – Micronaut 18

Slide 19

Slide 19 text

$ # No CLI available :-( $ # Requires Maven pre-installed $ # Requires Maven to create a Gradle project ;-)
 $ mvn io.quarkus:quarkus-maven-plugin:0.28.1:create \ -DprojectGroupId=com.github.fbascheper.odyssey \ -DprojectArtifactId=quarkus-demo \ -DclassName="com.github.fbascheper.odyssey.resource.VetResource" \ -Dpath="/vets" $ cd quarkus-demo $ ./mvnw quarkus:add-extension -Dextensions="agroal, hibernate-orm" $ ./mvnw compile quarkus:dev Getting started – Quarkus 19

Slide 20

Slide 20 text

Getting started – Quarkus • Or you can also use the Quarkus bootstrap page HTTPS://CODE.QUARKUS.IO • Select the extensions • And download the resulting zip-file 20

Slide 21

Slide 21 text

Agenda Introduction A Brief history of Java Space Getting started Feature comparison Developer friendly? Production ready? High scores Wrap-up 21 https://pixabay.com/p-683065/

Slide 22

Slide 22 text

Feature comparison 1. Language support 2. Framework support 3. Shell integration (*NIX) 4. Kubernetes support 22 https://pixabay.com/nl/photos/vintage-schaal-evenwicht-weegschaal-2862708/

Slide 23

Slide 23 text

• Java ✔ ✔ ✔ • Groovy ✔ ✘ ✔ • Kotlin ✔ ✔ ✔ • Scala ✘ ✔ ✔ Language support 23 MICRONAUT QUARKUS SPRING BOOT

Slide 24

Slide 24 text

Framework support • Java / Jakarta EE ✘ ✘ ✘ • Eclipse MicroProfile certified ✘ ✔ ✘ ‣ (Sub) specification support: - CDI ✔ ✔ ✔ - JSON-P / JSON-B ✔ ✔ ✔ - JAX-RS ✔ ✔ ✔ - JWT ✔ ✔ ✔ • Reactive Messaging ✔ ✔ ✔ 24 MICRONAUT QUARKUS SPRING BOOT

Slide 25

Slide 25 text

Framework support 25

Slide 26

Slide 26 text

Spring DI compatibility • QUARKUS provides a ‘Spring’ compatibility extension • With support for Spring framework annotations, such as ‣ @Autowired (with @Qualifier) ‣ @Component ‣ @Value • NOTE: THIS WILL NOT ‣ Start a Spring Application Context ‣ Run any Spring infrastructure classes 26

Slide 27

Slide 27 text

Spring DI compatibility • MICRONAUT also has integration for ‘Spring’ compatibility • With support for ‣ Spring framework annotations, events, … ‣ Spring boot annotations ‣ Spring MVC controllers • You can even use Micronaut as a parent application context • QUESTION: HOW MUCH SPRING DO YOU NEED??? 27

Slide 28

Slide 28 text

Command-line tools • Maven plugin ‣ Run application ✘ ✔ ✔ ‣ Hot reloading ✘ ✔ ✘ • Gradle support ✔ ✘ ✔ • Shell support ‣ New project ✔ ✘ ✔ ‣ Modify project ✔ ✘ ✘ 28 MICRONAUT QUARKUS SPRING BOOT

Slide 29

Slide 29 text

Cloud / Kubernetes support • Build Docker build ‣ Native compilation (GraalVM) ✔ ✔ ✘ • Read Kubernetes metadata ‣ ConfigMaps ✔ ✘ ✘ ‣ Secrets ✔ ✘ ✘ • Kubernetes Service Discovery ‣ Clients can discover Kubernetes services ✔ ✘ ✘ 29 MICRONAUT QUARKUS SPRING BOOT

Slide 30

Slide 30 text

Summing up • Quarkus ‣ MicroProfile 2.2 certified ‣ Hot code replacement • Micronaut ‣ Best Kubernetes support • Spring Boot ‣ Familiar to everyone ‣ Best language / framework support 30 https://pixabay.com/nl/photos/rekenmachine-nummer-3051722/ NO CLEAR WINNER !

Slide 31

Slide 31 text

Agenda Introduction A Brief history of Java Space Getting started Framework support Developer friendly? Production ready? High scores Wrap-up 31 https://pixabay.com/p-683065/

Slide 32

Slide 32 text

Developer Friendly? • Minimal requirements ‣ Documentation ‣ IDE Support ‣ Examples • Stack overflow ?! • Productivity ‣ Hot code replacement ‣ Single configuration 32

Slide 33

Slide 33 text

Developer Friendly? • Minimal requirements ‣ Documentation - similar ‣ IDE Support - SPRING BOOT ! ‣ Examples • Stack overflow ?! • Productivity ‣ Hot code replacement ‣ Single configuration 33 QUARKUS ! }

Slide 34

Slide 34 text

Various build types - with Quarkus 34 • Development build • Native image ‣ For your LOCAL operating system • Cross compilation $ ./mvnw compile quarkus:dev $ ./mvnw package -Pnative $ ./mvnw package -Pnative -Dnative-image.docker-build=true # Alternative: docker build -f src/main/docker/Dockerfile.multistage .\ WHAT’S THE DIFFERENCE ? / /

Slide 35

Slide 35 text

Quarkus development build 35 $ ./mvnw compile quarkus:dev

Slide 36

Slide 36 text

Quarkus development build 36 $ http :8080/vets EXISTING CODE OK !

Slide 37

Slide 37 text

Quarkus development build 37 @Path("/pets") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public class PetResource { @GET public List list() { return Pet.listAll(); } } CREATED NEW RESOURCE !

Slide 38

Slide 38 text

Quarkus development build 38 $ http :8080/pets TEST FAILED !

Slide 39

Slide 39 text

Quarkus development build 39 @Entity @Table(name = "pets") public class Pet extends NamedEntity { @ManyToOne @JoinColumn(name = "owner_id") @JsonbTransient public Owner owner; @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet", fetch = FetchType.EAGER) @JsonbTransient public Set visits = new LinkedHashSet<>(); } CODE FIXED !

Slide 40

Slide 40 text

Quarkus native image build - MacOS 40 ABOUT 4 MINUTES! $ ./mvnw package -Pnative

Slide 41

Slide 41 text

Quarkus cross-compile build 41 ABOUT 30 MINUTES! $ ./mvnw package -Pnative -Dnative-image.docker-build=true

Slide 42

Slide 42 text

http://www.buildwithcare.ca/images/footer_logo.png Developer Friendly? 42 YES, BUT …

Slide 43

Slide 43 text

Agenda Introduction A Brief history of Java Space Getting started Framework support Developer friendly? Production ready? High scores Wrap-up 43 https://pixabay.com/p-683065/

Slide 44

Slide 44 text

Production ready? • Minimal requirements ‣ Stable ‣ Secure (patches) ‣ Active (updates) • Nice to have ‣ Community ?! ‣ Support contracts?! 44

Slide 45

Slide 45 text

Performance timing • Startup time 3.448 s 3.430 s 0.019 s 5.564 s • Average request time after warmup (time http :8080/vets) ‣ Real 0.365s 0.307s 0.265s 0.270s ‣ User 0.263s 0.246s 0.210s 0.215s ‣ Sys 0.055s 0.044s 0.045s 0.045s 45 MICRONAUT QUARKUS-DEV QUARKUS-NATIVE SPRING BOOT

Slide 46

Slide 46 text

Agenda Introduction A Brief history of Java Space Getting started Framework support Developer friendly? Production ready? High scores Wrap-up 46 https://pixabay.com/p-683065/

Slide 47

Slide 47 text

<< Attribution >> 47 High scores

Slide 48

Slide 48 text

• You need native images ‣ GraalVM / Docker / Kubernetes ‣ Function as a Service applications • AND you can handle ‣ Living on the bleeding edge ‣ Frequent (weekly?) updates • AND you trust RedHat / IBM Choose Quarkus, if… 48

Slide 49

Slide 49 text

Choose Micronaut, if… • You need native images ‣ GraalVM / Docker / Kubernetes ‣ Function as a Service • BUT you cannot handle ‣ Living on the bleeding edge ‣ Frequent (weekly?) updates • OR you need something special ‣ Gradle / Groovy support ? 49

Slide 50

Slide 50 text

Choose Spring Boot, if… • You don’t need ‣ Native images ‣ Hot reloading (JRebel / DCEVM) ‣ … • OR You rely on JDK7, Reflection, … • OR You’re using Spring specific frameworks • OR you just want to be ‘safe’ 50

Slide 51

Slide 51 text

Agenda Introduction A Brief history of Java Space Getting started Framework support Developer friendly? Production ready? High scores Wrap-up 51 https://pixabay.com/p-683065/

Slide 52

Slide 52 text

Wrap-up

Slide 53

Slide 53 text

http://www.thebluediamondgallery.com/handwriting/q/questions.html 53

Slide 54

Slide 54 text

https://commons.wikimedia.org/wiki/File:Thank-you-word-cloud.jpg 54

Slide 55

Slide 55 text

Demo 55