BT

InfoQ Homepage News Micronaut 1.1 Features Enhanced Support for Building Cloud-Native Applications

Micronaut 1.1 Features Enhanced Support for Building Cloud-Native Applications

This item in japanese

Bookmarks

During the recent Google Cloud Next conference, Object Computing, Inc. (OCI) announced the release of Micronaut 1.1 featuring enhanced support for building cloud-native applications with new modules, Micronaut AWS and Micronaut RabbitMQ. There were also improvements to existing modules, Micronaut GCP, Micronaut gPRC and Micronaut GraphQL. A new Bean Introspection API that replaces the JDK Introspector class and new templates for the Micronaut Test module round out what’s new in Micronaut 1.1.

Initially known as Project Particle, Micronaut is a full-stack JVM-based framework for creating microservice-based, cloud-native and serverless applications that can be written in Java, Groovy, and Kotlin. Micronaut was introduced in March 2018 by Graeme Rocher, principal software engineer and Grails and Micronaut product lead at OCI, and was subsequently open-sourced in May 2018.

As stated in the announcement:

Micronaut 1.1 makes it even simpler to build efficient, cloud-ready applications that are simultaneously easy to test, easy to containerize, and efficient.

Micronaut can be deployed to both Google Cloud Run and Google App Engine Standard for Java 11, and with Micronaut 1.1, we have dedicated support for Google Stackdriver Trace.

We examine a few of the new features here.

Micronaut Profiles

Micronaut includes several built-in profiles that generate skeleton, yet working, applications as a building block for developing web or command line applications. Each profile consists of a template and additional commands specific to that profile. For example, create-app initiates the service profile that includes additional commands for building controller (create-controller) and client (create-client) classes that may not be available in other profiles.

Micronaut GCP

Micronaut GCP, an integration between Micronaut and Google Cloud Platform (GCP), is a module for running applications on GCP. First introduced with the release of Micronaut 1.0, this module has been enhanced to support Stackdriver Trace, a distributed tracing system “that collects latency data from your applications and displays it in the Google Cloud Platform Console.”

Micronaut GCP provides utilities including GoogleCloudConfiguration, a configuration class to establish and retrieve a GCP project ID, and GoogleCredentialsConfiguration, a class that helps facilitate creation of an instance of the GoogleCredentials class.

Stackdriver Trace may be enabled via Gradle or Maven dependencies:

    
compile 'io.micronaut.gcp:micronaut-gcp-tracing:1.0.0'
    
    
<dependency>
    <groupId>io.micronaut.gcp</groupId>
    <artifactId>micronaut-gcp-tracing</artifactId>
    <version>1.0.0</version>
</dependency>
    

An account on GCP and installation of the Google Cloud SDK is required.

Along with the announcement of Micronaut 1.1 at the recent Google Cloud Next conference, Jeff Scott Brown, principal software engineer, Core Grails development team and partner at OCI, presented Microservices on GCP Dramatically Simplified to demonstrate how to build and deploy microservices to GCP.

Micronaut AWS

Micronaut AWS, an integration between Micronaut and Amazon Web Services (AWS), is a new module that offers AWS Lambda serverless computing for Micronaut applications. There is also support for Alexa Skills and the AWS API Gateway, an alternative to Micronaut AWS that allows developers to implement their own custom Lambda custom runtime, such as GraalVM, that uses the AWS Serverless Java Container. The MicronautLambdaRuntime class provides an entry point to a custom Lambda runtime.

Micronaut AWS provides other utilities including AWSClientConfiguration, a base AWS SDK configuration class, and EnvironmentAWSCredentialsProvider, a class that reads defined AWS-specific environmental variables such as:

    
$ export AWS_ACCESS_KEY_ID=XXXX
$ export AWS_SECRET_KEY=YYYY
    

Using the environmental variables above and the EnvironmentAWSCredentialsProvider class, an AWS S3 Client may be established as follows:

    
AmazonS3ClientBuilder amazonS3ClientBuilder = AmazonS3ClientBuilder.standard();
amazonS3ClientBuilder.setCredentials(new EnvironmentAWSCredentialsProvider(applicationContext.getEnvironment()));
AmazonS3 s3 = amazonS3ClientBuilder.build();
    

Micronaut's create-function command (similar to create-app) builds a new project that is ready for deployment on AWS Lambda.

For example, consider the following Micronaut command:

    
$ mn create-function org-redlich-aws-app
    

As shown below, this will create a new Micronaut project using the parameter name, org-redlich-aws-app, for the project root directory, the source and test directory structure with corresponding packages name, and the filenames, OrgRedlichAwsApp.java and OrgRedlichAwsFunction.java. Corresponding tests are also generated.

Gradle and Maven dependencies for using Micronaut AWS are as follows:

    
compile 'io.micronaut:micronaut-function-aws'
    
    
<dependency>
    <groupId>io.micronaut</groupId>
    <artifactId>micronaut-function-aws</artifactId>
</dependency>
    

Micronaut RabbitMQ

Micronaut RabbitMQ, an integration between Micronaut and RabbitMQ, is a new module that offers message-driven microservices for Micronaut applications. RabbitMQ, an open source message broker, supports multiple messaging protocols and monitoring that can deployed in the enterprise and cloud. Messages produced and consumed within an application are handled with the RabbitMQ Java Client Library, an open-source library that allows Java code to interface with RabbitMQ.

Gradle and Maven dependencies for using Micronaut RabbitMQ are as follows:

    
compile 'io.micronaut.configuration:micronaut-rabbitmq'
    
    
<dependency>
    <groupId>io.micronaut.configuration</groupId>
    <artifactId>micronaut-rabbitmq</artifactId>
</dependency>
    

To create a Micronaut application using RabbitMQ features:

    
$ mn create-app my-rabbitmq-app --features rabbitmq
    

A new RabbitMQ-specific profile, included in Micronaut RabbitMQ, makes available the commands, create-rabbitmq-producer and create-rabbitmq-listener. Message services may be created using the new profile as follows:

    
$ mn create-app my-rabbit-service --profile rabbitmq

$ mn create-rabbitmq-producer Message
$ mn create-rabbitmq-listener Message
    

As shown below, the commands above will generate MessageProducer.java and MessageListener.java.

    
package micronaut.rabbitmq;

import io.micronaut.configuration.rabbitmq.annotation.RabbitClient;

@RabbitClient
public interface MessageProducer {

}
    
    
package micronaut.rabbitmq;

import io.micronaut.configuration.rabbitmq.annotation.RabbitListener;

@RabbitListener
public class MessageListener {

}
    

OCI offer developers a variety of step-by-step guides such as getting started, building event-driven applications with RabbitMQ, building a single-page application, among many others. Most of these guides offer examples in Java, Kotlin, and Groovy.

Resources

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.