BUILDING MICROSERVICESBUILDING MICROSERVICES
WITH MICRONAUTWITH MICRONAUT
ORACLE CODE ONEORACLE CODE ONE
September 18, 2019September 18, 2019
Michael P. RedlichMichael P. Redlich
1 . 1
WHO'S MIKE?WHO'S MIKE?
Bachelor of Science, Computer Science from
Senior Research Technician, petrochemical research
organization
Java Queue News Editor,
Past President,
(ACGNJ)
Founder & Co-Facilitator,
Rutgers University
InfoQ
Amateur Computer Group of New
Jersey
ACGNJ Java Users Group
1 . 2
OBJECTIVESOBJECTIVES
What is Micronaut?
Features
Why Micronaut?
JVM Language Support
Getting Started
Live Demo
2
WHAT IS MICRONAUT?WHAT IS MICRONAUT?
A full-featured, full-stack JVM-based lightweight
application framework for creating microservice-
based, cloud-native and serverless applications that
can be written in Java, Groovy, and Kotlin
Developed at (OCI)
, Principal Software Engineer and
Grails and Micronaut Product Lead at OCI
Object Computing, Inc.
Graeme Rocher
3 . 1
First introduced at the in March
2018
Designed from the ground up for microservices and
serverless applications
Latest version: 1.2.2
Greach Conference
3 . 2
PROJECTS (MODULES)PROJECTS (MODULES)
Micronaut AWS
Micronaut GCP
Micronaut RabbitMQ
Micronaut Test
Micronaut for Spring
Micronaut Security
3 . 3
Based on Ahead-of-Time compilation vs. runtime
re ection
runtime re ection has inherent memory and
performance costs
3 . 4
FEATURESFEATURES
HTTP SERVERHTTP SERVER
Fully reactive and non-blocking HTTP server built on
support for Reactor and
Auto con guration for common databases
Netty
RxJava
4 . 1
HTTP CLIENTHTTP CLIENT
Declarative, reactive, compile-time HTTP client
Automatic service discovery
Automatic load balancing
4 . 2
Support for:
(OpenAPI)
Amazon Web Services
Google Cloud Platform
GraalVM
GraphQL
gRPC
Swagger
4 . 3
Microservice patterns such as:
service discovery
distributed tracing
circuit breaker
4 . 4
WHY MICRONAUT?WHY MICRONAUT?
LET'S TRAVEL BACK IN TIME TO 2008LET'S TRAVEL BACK IN TIME TO 2008
Grails 1.0 released
Applications were monoliths
Before the advent of technologies such as:
Angular
React
Docker
Microservices
5 . 1
Attempt to t monolith-focused framework into
microservices environment
Spring and Grails weren't designed for the micro-
environment
5 . 2
Graeme RocherGraeme Rocher
Grails & Micronaut Lead at OCIGrails & Micronaut Lead at OCI
“We believe Micronaut is the basis for a framework
for the future, by resolving this tension by
eliminating all use of re ection and producing all
annotation metadata, proxies and framework
infrastructure at compilation time through a set of
annotation processors and AST transformations that
perform Ahead-of-Time (AOT) compilation. What this
allows Micronaut to achieve is blazing fast startup
time, low memory consumption and crucially
improved compatibility with GraalVM native image.”
5 . 3
LANGUAGE AND BUILD TOOLSLANGUAGE AND BUILD TOOLS
JVM LANGUAGESJVM LANGUAGES
6 . 1
BUILD TOOLSBUILD TOOLS
6 . 2
GETTING STARTEDGETTING STARTED
INSTALLING MICRONAUTINSTALLING MICRONAUT
$ sdk install micronaut
7 . 1
7 . 2
BUILT-IN PROFILESBUILT-IN PROFILES
Generate skeleton, yet working, applications as aGenerate skeleton, yet working, applications as a
building block for developing web or command linebuilding block for developing web or command line
applicationsapplications
create-app
create-controller
create-client
7 . 3
GENERATE AN INITIAL APPLICATIONGENERATE AN INITIAL APPLICATION
Default Language: JavaDefault Language: Java
$ mn create-app org.redlich.demo
$ mn create-app org.redlich.demo --lang groovy
$ mn create-app org.redlich.demo --lang kotlin
7 . 4
GENERATE AN INITIAL APPLICATIONGENERATE AN INITIAL APPLICATION
Default Build Tool: GradleDefault Build Tool: Gradle
$ mn create-app org.redlich.demo
$ mn create-app org.redlich.demo --build maven
7 . 5
7 . 6
GeneratedGenerated application.ymlapplication.yml lele
micronaut:
application:
name: demo
7 . 7
GeneratedGenerated micronaut-cli.ymlmicronaut-cli.yml lele
profile: service
defaultPackage: org.redlich
---
testFramework: junit
sourceLanguage: java
7 . 8
GeneratedGenerated Application.javaApplication.java lele
package org.redlich;
import io.micronaut.runtime.Micronaut;
public class Application {
public static void main(String[] args) {
Micronaut.run(Application.class);
}
}
7 . 9
$ ./gradlew run
$ ./mvnw compile exec:exec
7 . 10
7 . 11
$ mn create-controller HelloController
7 . 12
7 . 13
GeneratedGenerated HelloController.javaHelloController.java lele
package org.redlich;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.micronaut.http.HttpStatus;
@Controller("/hello")
public class HelloController {
@Get("/")
public HttpStatus index() {
return HttpStatus.OK;
}
}
7 . 14
DEMO APPLICATIONDEMO APPLICATION
A book inventory application built on three
microservices
Based on a written by
, senior software engineer at OCI
Uses , a distributed service mesh to connect,
secure, and configure services across any runtime
platform and public or private cloud
tutorial Sergio del Amo
Caballero
Consul
8 . 1
MICROSERVICESMICROSERVICES
books microservice (Groovy)
inventory microservice (Kotlin)
gateway microservice (Java)
8 . 2
8 . 3
BOOKS MICROSERVICE (GROOVY)BOOKS MICROSERVICE (GROOVY)
$ mn create-app example.micronaut.books --lang groovy
8 . 4
INVENTORY MICROSERVICE (KOTLIN)INVENTORY MICROSERVICE (KOTLIN)
$ mn create-app example.micronaut.inventory --lang kotlin
8 . 5
GATEWAY MICROSERVICE (JAVA)GATEWAY MICROSERVICE (JAVA)
$ mn create-app example.micronaut.gateway
8 . 6
9
NY/NJ/PA JAVA USERS GROUPSNY/NJ/PA JAVA USERS GROUPS

ACGNJ Java Users Group
facilitated by Mike Redlich & Barry Burd
NYJavaSIG
facilitated by Frank Greco
javasig.org
javasig.com
10 . 1
PhillyJUG
facilitated by Paul Burton, et.al.
Princeton Java Users Group
facilitated by Yakov Fain
meetup.com/PhillyJUG
meetup.com/NJFlex
10 . 2
FURTHER READINGFURTHER READING
INFOQ TECHNICAL ARTICLESINFOQ TECHNICAL ARTICLES
Sergio del Amo Caballero
December 6, 2018
Sergio del Amo Caballero
October 5, 2018
Micronaut Tutorial: Part 2: Easy Distributed Tracing, JWT Security
and AWS Lambda Deployment
Micronaut Tutorial: How to Build Microservices with This JVM-
Based Framework
11 . 1
INFOQ NEWSINFOQ NEWS
May 14, 2019
December 31, 2018
October 19, 2018
Micronaut 1.1 Features Enhanced Support for Building Cloud-
Native Applications
Micronaut for Spring Allows Spring Boot Apps to Run as
Micronaut Apps
The Road to Micronaut 1.0: A JVM-Based Full-Stack Framework
11 . 2
UPCOMING ACGNJ JAVA USERSUPCOMING ACGNJ JAVA USERS
GROUP MEETINGSGROUP MEETINGS
Tuesday, October 8, 2019
Tuesday, October 22, 2019
Monday, November 18, 2019
Beautiful SDK Design in Java for APIs
Reza Rahman
Ray Tsang
Micah Silverman
12
UPCOMING EVENTSUPCOMING EVENTS
Monday-Friday, November 11-15, 2019
Hyatt Regency San Francisco
QCon San Francisco
13
MICRONAUT RESOURCESMICRONAUT RESOURCES




Website
Guides
Documentation
News
14
CONTACT INFOCONTACT INFO





redlich.net
mike@redlich.net
@mpredli
slideshare.net/mpredli01
github.com/mpredli01/micronaut-
bookstore
15
ACKNOWLEDGEMENTSACKNOWLEDGEMENTS
Object Computing, Inc.
Graeme Rocher
Sergio del Amo Caballero
16
THANKS!THANKS!
17

Building Microservices with Micronaut: A Full-Stack JVM-Based Framework