Project Helidon-Introduction to Microservices Development with Java
Introduction
Helidon is a collection of Java libraries (aka framework) for writing microservices that run on a fast web core powered by Netty.
In case you’ve never heard about Netty, here is a quick description of it:
Netty is an asynchronous event-driven network application framework for the rapid development of maintainable high-performance protocol servers & clients.
With Netty, you can develop any kind of Cloud Native Microservices as it supports the vast majority of communication protocols.
The block diagram below gives the big picture of Netty’s components set as well as the several protocols it supports.
Now that you understand what Netty is, let’s return to the main topic of this blog post — Project Helidon!
Helidon can be summarized as a set of libraries that are lightweight, use a fast web core (Netty), and have the goal of addressing all the Microservices development requirements, both functional and non-functional, current and future ones.
From an IT governance point of view, it simplifies the DevOps process.
Helidon has support for health checks, metrics, tracing, and fault tolerance. It allows you to create cloud-ready applications that integrate with Prometheus, Zipkin, and Kubernetes for example.
Helidon addresses the 12-factor app methodology for Cloud Native Microservices. I strongly advise you to consider Helidon for your new projects.
This blog post explores some of its benefits.
Helidon provides both a Microprofile implementation as well as a new Microframework approach — which I love as I have designed many APIs that follow the fluent interface design pattern in the past.
The next section presents both approaches to microservices development with Helidon.
Microprofile approach
The Microprofile approach, with the Helidon MP implementation, uses the common MicroProfile specification as it provides Jakarta/Java EE developers with a straightforward Microservices development experience. This is the plain Java EE stuff with components like JAX-RS (Jersey), JSON-P, JSON-B, and CDI for example.
The Microprofile approach uses a declarative model (by means of good old Java Annotations) that supports the MicroProfile family of APIs. This will be familiar to Java EE developers. No tricks here!
Given that, the MicroProfile implementation runs on a fast Helidon Reactive WebServer based on Netty.
Microframework approach
On the other hand, one can use the Microframework approach with Helidon SE. It adopts a functional programming approach that uses the following Helidon components:
- WebServer;
- Config;
- Security.
This gives you full control over the core framework mechanisms as you can use them directly.
Helidon SE then uses a new fluent interface implementation, in order to implement reactive applications, the ones that compose what we can call reactive systems.
In case you need an introduction to Reactive Apps / Systems, please check the Reactive Manifesto.
In summary:
“Systems built as Reactive Systems are more flexible, loosely coupled, and scalable. This makes them easier to develop and amenable to change. They are significantly more tolerant of failure and when failure does occur they meet it with elegance rather than a disaster. Reactive Systems are highly responsive, giving users effective interactive feedback.” — The Reactive Manifesto
The Programming Model
Below you can see an example of Helidon MicroProfile (MP) with the classic Java Annotations approach:
public class GreetService {
@GET
@Path("/greet")
public String getMsg() {
return "Hello World!";
}
}
Now, we have the Helidon Microframework (SE) approach. Observe the use of a fluent interface (chained method calls):
WebServer.create(
Routing.builder()
.get("/greet", (req, res)
-> res.send("Hello World!"))
.build())
.start();
The Deployment Model
Helidon imposes no requirements in relation to its deployment model or tools you should use.
At the end of the day, your Cloud Native Microservice will be just a plain old Java application.
In that regard, you can use modules with the help of Java Platform Module System (JPMS) components.
Just to give you an idea of how easy it is, in order to run the previous example (code), you just need the Java SE and the Maven tool as shown below:
Build (with Maven tool):
$ mvn package
Run (use the Java interpreter to run a jar file):
$ java -jar target/myapp.jar
Test (with the curl command line tool):
$ curl -X GET http://localhost:8080/greet
Hello World!
Wrap-up
That’s it for this post!
The next blog posts will explore intermediate to advanced aspects of Microservices development with Helidon.
Meanwhile, check the resources below for more information. Stay tuned!
- Project Helidon: https://helidon.io/
- Javadocs — https://helidon.io/docs/latest/apidocs/
- GitHub: https://github.com/oracle/helidon
- Twitter: @helidon_project
- Microprofile.io — https://microprofile.io/
- Reactive programming vs. Reactive systems — https://oreil.ly/2MVF0sr
Oracle Developers and Oracle OCI Free Tier
Join our Oracle Developers channel on Slack to discuss Microservices, Java, JDBC, Oracle Cloud Infrastructure, Oracle Database, and other topics!
Build, test, and deploy your applications on Oracle Cloud — for free! Get access to OCI Cloud Free Tier!