@bufferings #kanjava It reminds me Spring Boot, so it was really easy for me to try. Micronaut @Controller public class Application { public static void main(String[] args) { Micronaut.run(Application.class); } @Get("/hello/{name}") public String hello(String name) { return "Hello " + name; } }
@bufferings #kanjava 1. Multiple WARs on one application server 2. One server for one app with VMs 3. PaaS, 12 Factor App & Container 4. Embedded Tomcat & executable JAR by Spring Boot 5. Kubernetes & Microservices Java 10 years around me
@bufferings #kanjava Currently we're doing a lot at Runtime. • Runtime Component Scan • Runtime DI & AOP It makes our app start slower & consume memory. Recent Java - Challenges
@bufferings #kanjava • Microservices in mind from the beginning • Inspired by Spring & Grails • First class support for Reactive based on Netty • Ahead of Time Compilation • Support for Java, Kotlin, Groovy • Support for GraalVM Native Image https://micronaut.io/ Micronaut
@bufferings #kanjava • Java code to a standalone executable • This executable does not run on the Java VM • but includes necessary components from “Substrate VM” • The resulting program has faster startup time • and lower runtime memory overhead https://www.graalvm.org/docs/reference-manual/aot-compilation/ GraalVM Native Image (early adopter)
@bufferings #kanjava My thoughts: • AOT compilation & Native Image would be popular in a few years • Many frameworks would start supporting them including Spring • and just I like Micronaut My Motivation
@bufferings #kanjava HTTP Server (Reactive) @Controller("/hello") public class HelloController { @Get("/{name}") public Single index(String name) { return Single.just("Hello " + name); } }
@bufferings #kanjava Validation (AOP) @Controller("/hello") public class HelloController { @Get("/{name}") public Single index(@Size(min = 10) String name) { return Single.just("Hello " + name); } } "message": "name: size must be between 10 and 2147483647"
@bufferings #kanjava Use Declarative HTTP Client for test @Inject HelloClient client; @Test public void testHello() { assertEquals("Hello World", client.hello("World")); }
@bufferings #kanjava Microservices in mind • HTTP Server, HTTP Client, Reactive based on Netty Fast startup & low memory footprint • DI & AOP with AOT Compilation GraalVM Native Image Support • makes our app start in a few hundreds of milliseconds Summary
@bufferings #kanjava Introduction to Micronaut: Lightweight Microservices with Ahead of Time Compilation by Graeme Rocher https://youtu.be/P1qp_l5EFic Micronaut | Technology Radar | ThoughtWorks https://www.thoughtworks.com/radar/languages-and- frameworks/micronaut References