MicroProfile 3.0 Support Comes to Helidon

We are proud to announce a new version of Helidon 1.3. The main feature of this release is MicroProfile 3.0 support, but it also includes additional features, bug fixes and performance improvements. Let’s take a closer look.

MicroProfile 3.0

About a month ago we released Helidon 1.2 with MicroProfile 2.2 support. Since that time we made a step forward and brought MicroProfile 3.0 support.

For those who don’t know, MicroProfile is a set of cloud-native Java APIs. It’s supported by most of the modern Java vendors like Oracle, IBM, Red Hat, Payara and Tomitribe which makes it a de-facto standard in this area. It’s one of the goals of Helidon project to support the latest versions of MicroProfile. The Helidon MicroProfile implementation is called Helidon MP and along with the reactive, non-blocking framework called Helidon SE it builds the core of Helidon.

MicroProfile 3.0 is a major release. It contains updated Metrics 2.0 with some backwards incompatible changes, HealthCheck 2.0 and Rest Client 1.3 with minor updates.

Although MicroProfile 3.0 is not backwards compatible with MicroProfile 2.2, we didn’t want to bring backwards incompatibility to Helidon. Helidon Version 1.3 supports both MicroProfile 2.2 and MicroProfile 3.0. Helidon MP applications can select the MicroProfile version by depending on one (and only one) of the following bundles.

For compatibility with MicroProfile 2.2:

<dependency>
    <groupId>io.helidon.microprofile.bundles</groupId>    
    <artifactId>helidon-microprofile-2.2</artifactId>
</dependency>

For compatibility with MicroProfile 3.0:

<dependency>
    <groupId>io.helidon.microprofile.bundles</groupId
    <artifactId>helidon-microprofile-3.0</artifactId>
</dependency>

Backward compatibility with MicroProfile 2.2 implies that every existing Helidon application that depends on helidon-microprofile-2.2 will continue to run without any changes. New applications created from the latest archetypes in Helidon 1.3 will depend on helidon-microprofile-3.0.

Metrics 2.0 Support

As mentioned above, MicroProfile Metrics 2.0 introduces a number of new features as well as some backward incompatible changes. The following is a summary of the changes:

  • Existing counters have been limited to always be monotonic
  • A new metric called a concurrent gauge is now supported
  • Tags are now part of MetricID instead of Metadata
  • Metadata is now immutable
  • Minor changes to JSON format
  • Prometheus format is now OpenMetrics format (with a few small updates)

The reader is referred to https://github.com/eclipse/microprofile-metrics/releases/tag/2.0.1 for more information.

Note: There have been some disruptive signature changes in class MetricRegistry. Several getter methods now return maps whose keys are of type MetricID instead of String. Applications upgrading to the latest version of MicroProfile Metrics 2.0 should review these uses to ensure the correct type is passed and thus prevent metric lookup failures.

Helidon SE applications that use metrics can also take advantage of the new features in Helidon 1.3. For example, MicroProfile Metrics 2.0 introduced the notion of concurrent gauges which are now also available in Helidon SE. To use any of these new features, Helidon SE applications can depend on:

<dependency>
    <groupId>io.helidon.metrics</groupId>
    <artifactId>helidon-metrics2</artifactId>
</dependency>

Existing Helidon SE applications can continue to build using the older helidon-metrics dependency.

HealthCheck 2.0 Support

HealthCheck 2.0 contains some breaking changes. The message body of Health check response was modified, outcome and state were replaced by status. Also readiness (/health/ready) and liveness (/health/live) endpoints were introduced for smoother integration with Kubernetes.

The original /health endpoint is not removed, so your old application will still work without any changes.

New specification introduces two new annotations @Liveness and @Readiness. In Helidon SE we introduced two corresponding methods addLiveness and addReadiness and deprecated the original add method.

JPA and JTA are Production Ready

In earlier versions of Helidon we introduced an early access version of JPA and JTA integration. We received feedback from our users, fixed some issues and improved performance. In version 1.3 we are moving JPA and JTA support from Early Access to Production Ready.

We also created a guide helping users to get familiar with this feature.

Hibernate Support

With 1.3.0 you can now use Hibernate as the JPA provider, or you can continue using EclipseLink. It’s up to you. The difference is one <dependency> element in your pom.xml.

For EclipseLink:

<dependency>
    <groupId>io.helidon.integrations.cdi</groupId
    <artifactId>helidon-integrations-cdi-eclipselink</artifactId
    <scope>runtime</scope>
</dependency>

For Hibernate:

<dependency>
    <groupId>io.helidon.integrations.cdi</groupId
    <artifactId>helidon-integrations-cdi-hibernate</artifactId
    <scope>runtime</scope>
</dependency>

As with our EclipseLink support, Helidon’s Hibernate JPA integration features full Java EE-mode compatibility, including support for EJB-free extended persistence contexts, JTA transactions and bean validation. It works just like the application servers you may be used to, but inside Helidon’s lightweight MicroProfile environment.

GraalVM Improvements

Supporting GraalVM is one of our goals. In each release we are continuously improving GraalVM support in Helidon SE. This version brings support of GraalVM version 19.2.0. Also now you can use Jersey Client in Helidon SE application and build a native-image for it.

Example code:

private void outbound(ServerRequest request, ServerResponse response) {
    // and reactive jersey client call
    webTarget.request()
        .rx()
        .get(String.class)
        .thenAccept(response::send)
        .exceptionally(throwable -> {
            // process exception
            response.status(Http.Status.INTERNAL_SERVER_ERROR_500);
            response.send("Failed with: " + throwable);
            return null;
    });
}

We also added a guide explaining how to build a GraalVM native image from your Helidon SE application. Check it out.

New Guides

To simplify Helidon adoption process we added plenty of new guides explaining how to use various Helidon features.

Getting Started

Basics

Persistence

Build and Deploy

Tutorials

Other features

This release includes many bug fixes, performance improvements and minor updates. More information about changes you can find in the release notes.

Helidon on OOW/CodeOne 2019

Next week (Sep 16, 2019) Oracle Open World and CodeOne open doors for all attendees. Helidon is well covered there. There are some Helidon-related talks from Helidon team where we will introduce some new features like Helidon DB Client coming soon to Helidon as well as talks from our users covering different Helidon use cases. Here is a full list:

  • Non-blocking Database Access in Helidon SE [DEV5365]
    Monday, September 16, 09:00 AM — 09:45 AM
  • Migrating a Single Monolithic Application to Microservices [DEV5112]
    Thursday, September 19, 12:15 PM — 01:00 PM
  • Hands on Lab: Building Microservices with Helidon
    Monday, September 16, 05:00 PM — 07:00 PM
  • Building Cloud Native Applications with Helidon [CON5124]
    Wednesday, September 18, 09:00 AM — 09:45 AM
  • Helidon Flies Faster on GraalVM [DEV5356]
    September 16, 01:30 PM — 02:15 PM
  • Helidon MicroProfile: Managing Persistence with JPA [DEV5376]
    Thursday, September 19, 09:00 AM — 09:45 AM

See you on CodeOne!

Helidon brings MicroProfile 2.2+ support

We are pleased to announce the 1.2.0 release of Helidon. This release adds support for MicroProfile 2.2 and includes additional bug and performance fixes. Let’s take a closer look at what’s in the release.

MicroProfile

MicroProfile is now a de-facto standard for Java cloud-native APIs. One of the main goals of project Helidon is to deliver support for the latest MicroProfile APIs. The Helidon MicroProfile implementation is called Helidon MP and along with the reactive, non-blocking framework called Helidon SE it builds the core of Helidon.

We have been adding support for newer MicroProfile specifications one by one during the last few releases. The 1.2.0 release brings MicroProfile REST Client 1.2.1 and Open Tracing 1.3. With these pieces in place we now have full MicroProfile 2.2 support.

The full list of supported MicroProfile and Java EE APIs is listed on this image:

As you see, we added support for two more Java EE APIs: JPA (Persistence) and JTA (Transaction). It’s in early access at the moment. You should consider it as a preview. We are still working on it and the implementation and configuration is subject to change.

Here are some examples of using new APIs added in Helidon 1.2.0.

MicroProfile REST Client sample

Register a rest client interface (can be the same one that is implemented by the JAX-RS resource). Note that the URI can be overridden using configuration.

@RegisterRestClient(baseUri = "http://localhost:8081/greet")
public interface GreetResource {
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    JsonObject getDefaultMessage();
    
    @Path("/{name}")
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    JsonObject getMessage(@PathParam("name") String name);
}

Declare the rest client in a class using it (such as a JAX-RS resource in a different microservice):

@Inject
@RestClient
private GreetResource greetService;

And simply use the field to invoke the remote service (this example proxies the request to the remote service):

@GET
@Produces(MediaType.APPLICATION_JSON)
public JsonObject getDefaultMessage() {
    return greetService.getDefaultMessage();
}

Health Check 2.0 sample

Health Check 2.0 has two types of checks (in previous versions a single type existed):

  • Readiness — used by clients (such as Kubernetes readiness check) to check if the service has started and can be used
  • Liveness — used by clients (such as Kubernetes liveness checks) to check if the service is still up and running

Simply annotate an application scoped bean with the appropriate annotation (@Readiness or @Liveness) to create a health check:

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
import org.eclipse.microprofile.health.Liveness;

@Liveness
@ApplicationScoped
public class GreetHealthcheck implements HealthCheck {
    private GreetingProvider provider;
  
    @Inject
    public GreetHealthcheck(GreetingProvider provider) 
        this.provider = provider;
    }

    @Override
    public HealthCheckResponse call() {
        String message = provider.getMessage();
        return HealthCheckResponse.named("greeting")
            .state("Hello".equals(message))
            .withData("greeting", message)
            .build();
    }
}

Open Tracing Sample

MP Open Tracing adds a single annotation: @Traced, to add tracing to CDI beans.

Tracing of JAX-RS resources is automated (and can be disabled with the @Traced). Example of the bean used in the Health check example (the method getMessage is traced):

@ApplicationScoped
public class GreetingProvider {
    private final AtomicReference<String&gt; message = new AtomicReference<&gt;();
    
    /**
     * Create a new greeting provider, reading the message 
     * from configuration.
     *
     * @param message greeting to use
     */
    @Inject
    public GreetingProvider(
        @ConfigProperty(name = "app.greeting") String message) {
        this.message.set(message);
    }
    
    @Traced(operationName = "GreetingProvider.getMessage")
    String getMessage() {
        return message.get();
    }
    
    ...
}

Other Enhancements

In addition to MicroProfile 2.2, Helidon 1.2.0 contains a couple other enhancements:

  • HTTP Access Log support for Helidon MP and SE.
  • Early Access: Oracle Universal Connection Pool support: this lets you configure and inject the Oracle UCP JDBC driver as a DataSource in your Helidon MP application.

More to Come

With MicroProfile 2.2 support, Helidon has caught up with most of the other main MicroProfile implementations. We are now pushing Helidon towards MicroProfile 3.0, and we’ve already taken the first steps. That’s why we put a plus after 2.2 in the title. We already have support for Health Check 2.0 (and we’ll support it in a backwards compatible way). That leaves Metrics 2.0 and REST Client 1.3 and we are working hard to deliver it next month.

Stay tuned!

Thanks to Tomas Langer for helping with samples and to Joe Di Pol for great conversational style.

Helidon flies faster with GraalVM

GraalVM is an open source, high-performance, polyglot virtual machine developed by Oracle Labs. GraalVM offers multiple features, including the ability to compile Java code ahead-of-time into a native executable binary. The binary can run natively on the operating system, without a Java runtime

A native executable offers important benefits, like shorter startup time and lower memory footprint. In addition, when a native executable runs within a container, the size of the container image is reduced (when compared with the same Java application running in a traditional JVM), because the container image doesn’t include a Java runtime. An optimized container size is critical for deploying apps to the cloud.

We are pleased to announce that, starting with version 1.0.3, Helidon supports the GraalVM native-image capability. Now you can easily compile your Helidon application into a native executable with all the advantages described earlier. For example, the sample application described in this article has a startup time measured in tens of milliseconds and a MacOS executable size of only 21MB. Both of those numbers are higher when a traditional JVM is used.

On the other hand, everything is always a tradeoff. Long running applications on traditional JVMs are still demonstrating better performance than GraalVM native executables due to runtime optimization. The key word here is long-running; for short-running applications like serverless functions native executables have a performance advantage. So, you need to decide yourself between fast startup time and small size (and the additional step of building the native executable) versus better performance for long-running applications.

Compiling to native binaries introduces certain restrictions for your application. Because of native compilation, you must identify all the points in your code where reflection is used, which is not possible if CDI runtime injection is used. Helidon MP supports MicroProfile standards, which require CDI 2.0. Also, Helidon CDI cloud extensions are implemented as CDI plugins. We didn’t want to limit or complicate the user experience with Helidon MP; so GraalVM is supported in only Helidon SE. It is a perfect fit, because Helidon SE is designed to build small, reactive microservices. It doesn’t use dependency injection, annotations and other such magic . All the Helidon SE features and components (WebServer, Config, Security, Metrics, and Health Checks) are compatible with GraalVM native images.

Helidon supports two convenient GraalVM profiles:

  • The local profile is for users who have GraalVM installed locally and want to build a native executable for the same OS that they work on.
  • The Docker profile is for users who don’t have GraalVM installed locally or want to build native executable for Linux while using macOS locally.

Due to the possibility of backwards incompatible changes in GraalVM before the final release, the GraalVM support in Helidon is experimental. It’s been tested on GraalVM version RC13; it is not guaranteed to work on other GraalVM versions.

To get you started, Helidon has a quickstart sample, which you can use as a template for your Helidon-on-GraalVM application.

Generate the project using a Maven archetype:

mvn archetype:generate -DinteractiveMode=false \
    -DarchetypeGroupId=io.helidon.archetypes \
    -DarchetypeArtifactId=helidon-quickstart-se \
    -DarchetypeVersion=1.0.3 \
    -DgroupId=io.helidon.examples \
    -DartifactId=helidon-quickstart \
    -Dpackage=io.helidon.examples.quickstart

To build using the local profile you need to download GraalVM, extract it to some folder on your computer and define GRAALVM_HOME environment variable pointing to it.

If you use macOS, GRAALVM_HOME must point to Contents/Home directory inside the GraalVM root as it’s shown below.

export GRAALVM_HOME=~/graalvm-ce-1.0.0-rc13/Contents/Home

Build the project:

mvn package -Pnative-image

Run it:

./target/helidon-quickstart

If you want to use Docker profile, GraalVM installation is not required. Use the following command to build a docker image:

docker build -t helidon-native -f Dockerfile.native .

Run it as:

docker run --rm -p 8080:8080 helidon-native:latest

Helidon is a Java framework designed from scratch for writing microservices. It provides everything that you need to create small and efficient Java applications. It offers two programming models: reactive, and imperative supporting MicroProfile.

With GraalVM support, Helidon is one of the best solutions in the market for developing cloud-native microservices!

Do join our open-source community! We care about our users, and are ready to support you and answer your questions.

Update

We tested it with newly released GraalVM RC16 (both CE and EE versions) and it perfectly works.

Helidon 1.0 is Released

I am proud to announce that Helidon 1.0 is released. This version brings full MicroProfile 1.2 support in Helidon MP, support for Yasson and Jackson in Helidon SE, and contains bug fixes and performance improvements. We have finished the API changes that we’ve been working on over the last few months. From this point on we will have much greater API stability.

More details are in release notes.

Helidon Takes Flight

Today is a great day. Today we introduce a new Java microservices frameworks and a new member of MicroProfile family. Please welcome Project Helidon — a new Java open source microservices framework from Oracle.

Helidon is a Greek word for “swallow”, a type of bird that according to Wikipedia has “a slender, streamlined body and long pointed wings, which allow great manoeuvrability and… very efficient flight”. Perfect for darting through the clouds.

Continue reading