BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Significant New Features Planned for Helidon 2.0

Significant New Features Planned for Helidon 2.0

This item in japanese

Lire ce contenu en français

Less than a year after the formal release of Helidon 1.0, Oracle is well on their way to a formal release of Helidon 2.0, which is scheduled for late Spring 2020. Helidon 2.0.0-M1, released in early February, and Helidon 2.0.0-M2, released in late March, have provided the Java community with previews of significant new features including: support for reactive messaging and streams; a new command-line tool, a new web client API for Helidon SE, GraalVM support for Helidon MP, and a new reactive database client.

Support for GraalVM, introduced with the release of Helidon 1.0.3, was only available for Helidon SE applications. Helidon MP applications could not take advantage of GraalVM due to the use of reflection within CDI. As one of the most requested features by the Java community, Helidon 2.0.0-M1 introduced support to convert Helidon MP applications to native executable code with GraalVM. Tomas Langer, consulting member of technical staff at Oracle, has created this demo application for the Java community to preview this new feature.

To complement the original three core Helidon SE APIs - Web Server, Configuration and Security - a new API, Web Client, completes the set for Helidon SE. Web Client processes HTTP requests and responses related to a specified endpoint. Just like the Web Server API, Web Client may also be configured via an applications.yaml file:

    
server:
  port: 8080
  host: 0.0.0.0

client:
  connect-timeout-millis: 2000
  read-timeout-millis: 2000
  follow-redirects: true
  max-redirects: 5
  headers:
    - name: "Accept"
        value: ["application/json","text/plain"]
  services:
    exclude: ["some.webclient.service.Provider"]
    config:
      metrics:
        - methods: ["PUT", "POST", "DELETE"]
          type: COUNTER
          name-format: "client.counter.%1$s.%2$s"
    

Consider a small example where an instance of the WebClient interface is built and a response defined to return plain text:

    
WebClient client = WebClient.builder()
        .baseUri("http://localhost")
        .build();

CompletionStage<String> response = webClient.get()
        .path("/endpoint")
        .request(String.class);
    

To change the response to return JSON, simply build an instance of the JsonProcessing class and change the definition of the response variable:

    
JsonProcessing jsonProcessing = JsonProcessing.create();
CompletionStage<JsonObject> response = webClient.get()
        .path("/endpoint")
        .register(jsonProcessing.newReader())
        .request(JsonObject.class);
    

To address the challenges associated with reactive applications connecting to JDBC databases that, by design, are non-reactive, Helidon 2.0.0-M1 introduced the new DB Client that will provide consistent reactive database access and queries for Helidon SE applications. DB Client supports relational databases that connect via JDBC and reactive drivers for MongoDB. This new API will feature the ability to specify database connections and write native query code in a configuration file such that making database-related changes can easily be made without having to recompile code:

    
db:
  source: "jdbc"
  connection:
    url: "jdbc:mysql://127.0.0.1:3306/pokemon?useSSL=false"
    username: "user"
    password: "password"
    poolName: "mysql"
  statements:
    ping: "DO 0"
    select-all-pokemons: "SELECT id, name FROM Pokemons"
    

Support for metrics, health checks and tracing in DB Client will also be included. The Helidon team has created this demo application for the Java community to preview this new feature.

Introduced in Helidon 2.0.0-M2, developers can now create, build and run Helidon applications via the command line with the new Helidon CLI tool. Similar to hot reloading provided by Quarkus (quarkus:dev), a built-in development loop monitors source files that triggers a restart of the application upon changes to the source code. A separate download and installation is required. Once installed, the available command-line options are shown below:

Asynchronous messaging is an integral part of microservices applications. To that end, implementations of the MicroProfile standalone APIs, Reactive Messaging and Reactive Streams Operators, will be introduced in version 2.0. Both APIs will be available for Helidon SE and Helidon MP applications. However, only Reactive Messaging will be available for Helidon MP. To better align with the Helidon SE APIs, an equivalent Reactive Messaging API is planned for a future release. Helidon will also support Kafka for Reactive Messaging with additional connectors planned for a future release.

The Java community can expect some breaking changes with the final release of Helidon 2.0. Most notably, support for Java 8 has been dropped and JDK 11 will be the minimum Java version required for building Helidon applications. Some Helidon packages will also be removed in favor of corresponding packages found in java.util, java.lang and java.io. Details of all the changes in Helidon 2.0 may be found in the change log.

Resources

Rate this Article

Adoption
Style

BT