Definition

Micronaut framework

Micronaut is an open source JVM-based software framework for building lightweight, modular applications and microservices. Micronaut is known for its ability to help developers create apps and microservices with small memory footprints and short startup times. An important advantage of the Micronaut framework is that startup time and memory consumption are not tied to the size of an app's codebase. This makes the development of integration tests much easier and their execution much faster.

A big difference between Micronaut and other frameworks is that Micronaut analyzes metadata as soon as the application is compiled. During this compilation phase Micronaut will generate an additional set of classes that represent the state of the application already preconfigured. This enables dependency injection (DI) and aspect-oriented programming (AOP) behavior to be applied much more efficiently when the application finally runs.

Micronaut, which was introduced in 2018 by the creators of the Grails framework, provides native support for service discovery, distributed configuration, client-side load balancing and authentication. The framework is licensed under the Apache License v2 and the Micronaut Foundation oversees best practices and documentation.

What should developers know about Micronaut?

The Micronaut framework was designed for building and testing low-memory microservices, serverless applications and message-driven microservices.

It does this by avoiding the common disadvantages of most traditional Java frameworks, including runtime reflection for dependency injection, dynamic classloading, runtime byte code generation and proxy generation. The framework was designed specifically with cloud architecture in mind. Apache Maven and Gradle can be used as build tools.

Components of the modular framework predefine how programmers address the following:

  • dependency injection
  • inversion of control (IoC)
  • aspect-oriented programming (AOP)
  • configuration and configuration sharing
  • service discovery
  • HTTP routing
  • client-side load-balancing
  • proxies

How does Micronaut work?

Micronaut is designed to function as both a client and server framework. The framework features an annotation-based programming model that is very similar to the Java Spring framework. Unlike the Spring framework, however, Micronaut does not use Java Reflection APIs. Instead, it integrates directly with the Java compiler through annotation processors. This allows Micronaut to compute an additional set of classes that sit alongside user-defined classes. The classes serve to perform dependency injection, as well as define compilation time and aspect-oriented proxies in a completely reflection-free manner.

Because of the way Micronaut integrates directly with language compilers, however, the only JVM languages Micronaut can currently support are Java, Kotlin or Groovy. Plans exist to introduce support for other languages in the future.

Why is Micronaut so well-suited for microservices?

Micronaut has many features that are tailor-made for microservices, including the following:

Reactive Streams. Micronaut supports any framework that implements the Reactive Streams standard. The framework also integrates with reactive database drivers for SQL and NoSQL databases.

Message-driven microservices. Micronaut supports many different messaging systems, including Kafka, RabbitMQ, MQTT, JMS and NATS.io. Pulsar support is planned for a future release.

Serverless functions. Micronaut supports the development, testing and deployment of serverless functions for many different cloud providers, including AWS Lambda, Oracle Functions, Google Cloud Functions and Azure Functions.

OpenAPI documentation. Micronaut creates a YAML file at compilation time that can be added as a static resource later on or served through the browser using tools such as Swagger UI.

GraalVM-ready. Micronaut applications can be compiled into GraalVM native images to reduce startup times even more. GraalVM uses a closed-world static analysis approach to produce native images that require configuration for any dynamic parts of the application. Micronaut's relative lack of reflection and dynamic classloading mean that less configuration is required to get a GraalVM native image operational.

What are some alternatives to Micronaut?

Alternatives to the Micronaut framework include:

Some frameworks in the list above, including ASP.NET and Spring, have begun to integrate some of the ideas pioneered by Micronaut.

This was last updated in February 2021

Continue Reading About Micronaut framework

Dig Deeper on Enterprise architecture management

Software Quality
Cloud Computing
TheServerSide.com
Close