32

Meet Helidon,  a new open source Java microservices framework

 5 years ago
source link: https://www.tuicool.com/articles/hit/BN7b2yV
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

If you need an easier way to build microservices, you should give Project Helidon a try. Although Oracle has just open sourced this set of Java libraries, the project itself is not new, as Dmitry Kornilov, Helidon Project Lead explained in a recent  blog post . Work started some time ago and the tech giant is already using it in over 10 projects.

Project Helidon (which means swallow in Greek) is meant to make the experience of building microservices more pleasant – you could, of course, use Java EE for that but when there’s a framework readily available, why not use it?

We wanted to create a lightweight set of libraries that didn’t require an application server and could be used in Java SE applications. These libraries could be used separately from each other, but when used together would provide everything a developer needs to create a microservice:  configurationsecurity, and a  web server .

– Dmitry Kornilov

Project Helidon: Features

Simple & fast

It’s easy to use Helidon; since the project is a collection of libraries running on a fast Netty core, you won’t have to worry about extra overhead or bloat.

Reactive WebServer

Helidon Reactive WebServer is lightweight, flexible and reactive and acts as a simple to use -not to mention fast- foundation for your microservices.

Observable and resilient

If writing cloud-ready applications that integrate with Prometheus, Zipkin and Kubernetes is what you want, then Helidon is the right project for you. Did we mention that it offers support for health checks, metrics, tracing and fault tolerance?

MicroProfile support

Helidon supports MicroProfile and provides familiar APIs like JAX-RS, CDI and JSON-P/B. The MicroProfile implementation runs on Helidon Reactive WebServer.

Overview

The foundation of Helidon is composed of three elements:

  • WebServer:  A programmatic HTTP API with reactive features, powered by Netty.
  • Config:  A flexible configuration framework with support for multiple sources and formats
  • Security:  A tool-chain to handle authentication, authorization and context propagation.

Users can choose from one of two programming models:

  • Helidon SE: a functional programming style that uses the Helidon WebServer, Config and Security APIs directly. This way, you’ll have full transparency and control. JDK is used as runtime.
  • Helidon MP  is more declarative and supports the  MicroProfile  family of APIs. If you’re a Java EE/Jakarta EE developer, you should be familiar with this model.

Have a look at the  quickstart examples before you get started with either of the two programming models.

Getting started

The easiest way to start using this set of libraries is if you use a Maven project with Java 8 (or higher version) and configure the Helidon  bom-pom.

<dependencyManagement>
   <dependencies>
       <dependency>
           <groupId>io.helidon</groupId>
           <artifactId>helidon-bom</artifactId>
           <version>${helidon-version}</version>
           <type>pom</type>
           <scope>import</scope>
       </dependency>
   </dependencies>
</dependencyManagement>

The Hello World implementation for Helidon SE looks like this:

Routing routing = Routing.builder()
       .get("/hello", (req, res) -> res.send("Hello World"))
       .build();

WebServer.create(routing)
       .start();

For Helidon MP, you need to create a JAX-RS resource class to process your requests

@Path("hello")
@RequestScoped //allows us to use CDI injection
public class HelloWorld {
   @GET
   @Metered
   public String hello() {
       return "Hello World";
   }
}

After that, you’ll have to start the server with this resource:

Server.builder()
       .addResourceClass(HelloWorld.class)
       .build()
       .start();

and create beans.xml file in the  src/main/resources/META-INF directory to trigger CDI injection in this project:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee                          
                           http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
       bean-discovery-mode="annotated">
</beans>

This would start a webserver on the default port (7001) and expose endpoint “/hello” .

What’s next for Project Helidon

The team behind this project is working on implementing the next MicroProfile version, as well as on GraalVM support, Dmitry said in the blog post.

To make sure you don’t miss any of the upcoming features, check out the website and GitHub repo and follow them on Twitter

If you want to learn more about this project, there will be some Helidon-related talks at Oracle Code One 2018 and the team will participate in the Jakarta EE/MicroProfile Community Day at EclipseCon Europe 2018.

asap


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK