Micronaut: A Modern Microservice Framework for the JVM_A modern, JVM-based, full-stack framework for building modular, easily testable microservice applications._micronaut.io
Micronaut is a new full-stack framework build from the ground by the Grails team officially announced at Greach 2018. It focuses on modularity, minimal memory footprint and startup time which makes it a perfect solution for running on AWS lambda or similar environments. Server written in Java requires less than one second to start with minimal JAR size of 8 MB. Micronaut supports Java, Groovy and Kotlin language.
Key things about Micronaut
The main advantage of Micronaut is that there are no runtime penalty for holding metadata for configuration and dependency injection. You can think about Micronaut as Spring without any runtime reflection. Every information is handled at compile time using Groovy AST transformation or AST processors for Java and Kotlin. Micronaut uses internal dependency injection module inspired by Spring which leverages the official JSR-330 Context and Dependency Injection annotations.
Micronaut code looks very similar to Spring Boot with Spring Cloud enabled. You can write HTTP servers and HTTP clients with seamless load balancing. There is out-of-box support for service discovery, Hystrix, trace logging, caching, fault tolerance and circuit breaker pattern. Reactive Streams support is integral part of the framework so your controllers and clients can use for example RxJava 2 objects for input and output such as Single<MyObject>
.
Controller Example
@Controller("/") class HelloController {
@Get("/hello/{name}") String hello(String name) {
return "Hello $name"
}
}
Client Example
@Client("/") interface HelloClient {@Get('/hello/{name}') Single<String> hello(String name)}
Fallback Client Example
@Fallback class HelloFallbackClient {Single<String> hello(String name) {return Single.just("Hello fallback $name")}}
Similar to Spring Boot you can declare your own auto-configurable beans using @Requires
annotation. It also shares the configuration properties with Spring Boot. You can even use SPRING_APPLICATION_JSON
environment property for backend compatibility. You can use environment-specific properties for example application-aws.yml
for deployment to AWS.
Micronaut shares some of the parts with Grails — you will be able to use for example GORM from within your Micronaut microservice.
Micronaut is not available to public yet. The release is planned in Q2 2018 which means it will be probably released at Gr8Conf EU, which will also host talks dedicated to this new framework. Companies interested to try Micronaut may ask OCI for beta access.
You can see more details about Micronaut in following slides by Álvaro Sánchez-Mariscal:
Edit: First milestone of Micronaut has been released at Gr8Conf EU as expected. Visit the download section to get started. Preferred option is to use SDKMAN!:
curl -s https://get.sdkman.io | bashsource "$HOME/.sdkman/bin/sdkman-init.sh"sdk install micronautmn -version
The documentation is already very comprehensive:
Micronaut_In addition, with Micronaut your application startup time and memory consumption is not bound to the size of your…_docs.micronaut.io
There are also several guides available already:
Micronaut: A Modern Microservice Framework for the JVM_A modern, JVM-based, full-stack framework for building modular, easily testable microservice applications._guides.micronaut.io