DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Enterprise AI Trend Report: Gain insights on ethical AI, MLOps, generative AI, large language models, and much more.

2024 Cloud survey: Share your insights on microservices, containers, K8s, CI/CD, and DevOps (+ enter a $750 raffle!) for our Trend Reports.

PostgreSQL: Learn about the open-source RDBMS' advanced capabilities, core components, common commands and functions, and general DBA tasks.

AI Automation Essentials. Check out the latest Refcard on all things AI automation, including model training, data security, and more.

Related

  • Jakarta Security and REST in the Cloud: Part 2 Getting to Know the Basics
  • Unlocking the Power of Oracle NoSQL With Quarkus: Seamless Integration for Cloud-Age Applications
  • Keep Your Application Secrets Secret
  • Legacy Code Refactoring: Tips, Steps, and Best Practices

Trending

  • Role-Based Multi-Factor Authentication
  • The Rise of the Platform Engineer: How to Deal With the Increasing Complexity of Software
  • Behavior-Driven Development (BDD) Framework for Terraform
  • Advanced-Data Processing With AWS Glue
  1. DZone
  2. Software Design and Architecture
  3. Microservices
  4. Unveiling the Power of Helidon 4: A Dive Into New Features

Unveiling the Power of Helidon 4: A Dive Into New Features

Helidon 4 introduces cutting-edge features for streamlined microservices development with newly released groundbreaking features.

By 
Andrei Tuchin user avatar
Andrei Tuchin
DZone Core CORE ·
Dec. 28, 23 · Tutorial
Like (3)
Save
Tweet
Share
7.2K Views

Join the DZone community and get the full member experience.

Join For Free

In the ever-evolving landscape of microservices development, Helidon has emerged as a beacon of innovation. The release of Helidon 4 brings forth a wave of enhancements and features that promise to redefine the way developers approach microservices architecture. In this article, we embark on a detailed journey, unraveling the intricacies of Helidon 4's new features through insightful examples. From MicroProfile 6.0 compatibility to enhanced support for reactive programming, simplified configuration management, and seamless integration with Oracle Cloud Infrastructure (OCI), Helidon 4 positions itself at the forefront of modern microservices frameworks.

The Shift From Netty: Why Simplicity Matters

Netty, known for its efficiency and scalability, played a crucial role in powering Helidon's HTTP server in earlier versions. However, as Helidon evolved, the framework's maintainers recognized the need for a simpler and more approachable architecture. This led to the decision to move away from Netty, making room for a more straightforward and user-friendly experience in Helidon 4.

In previous versions, setting up a Helidon web server with Netty involved configuring various Netty-specific parameters. With Helidon 4, the process is more straightforward.

Java
 
public class SimpleWebServer {
    public static void main(String[] args) {
        WebServer.create(Routing.builder()
            .get("/", (req, res) -> res.send("Hello, Helidon 4!"))
            .build())
            .start()
            .await();
    }
}


In this example, the simplicity is evident as the developer creates a web server with just a few lines of code, without the need for intricate Netty configurations. 

Routing, a fundamental aspect of microservices development, becomes more intuitive.

Java
 
public class SimpleRouting {
    public static void main(String[] args) {
        WebServer.create((req, res) -> {
            if (req.path().equals("/hello")) {
                res.send("Hello, Helidon 4!");
            } else {
                res.send("Welcome to Helidon 4!");
            }
        }).start().await();
    }
}


This example showcases the streamlined routing capabilities of Helidon 4, emphasizing a more natural and less verbose approach.

MicroProfile 6.0: A Synergistic Approach

Helidon 4's support for MicroProfile 6.0 signifies a crucial alignment with the latest standards in the microservices landscape. Developers can now leverage the enhancements introduced in MicroProfile 6.0 seamlessly within their Helidon applications, ensuring compatibility and interoperability with other MicroProfile-compliant services. 

MicroProfile Config simplifies the configuration of microservices, allowing developers to externalize configuration parameters easily. In Helidon 4, MicroProfile Config is seamlessly integrated, enabling developers to harness its power effortlessly. 

Java
 
public static void main(String[] args) {
	String appName = ConfigProvider.getConfig().getValue("app.name", String.class);
	System.out.println("Application Name: " + appName);
}


In this example, the MicroProfile Config API is used to retrieve the value of the "app. name" configuration property, showcasing how Helidon 4 integrates with MicroProfile Config for streamlined configuration management. 

MicroProfile Fault Tolerance introduces resilience patterns to microservices, enhancing their fault tolerance. Helidon 4 seamlessly incorporates these patterns into its microservices development model. 

Java
 
public class FaultToleranceExample {
    @CircuitBreaker(requestVolumeThreshold = 4)
    public void performOperation() {
        // Perform microservice operation
    }
}


In this example, the @CircuitBreaker An annotation from MicroProfile Fault Tolerance defines a circuit breaker for a specific microservice operation, showcasing Helidon 4's support for fault tolerance. 

Enhanced Support for Reactive Programming

Helidon 4 places a strong emphasis on reactive programming, offering developers the tools to build responsive and scalable microservices. 

Java
 
// Reactive programming with Helidon 4
WebServer.create(Routing.builder()
    .get("/reactive", (req, res) ->
        res.send("Hello, Reactive World!"))
    .build())
    .start()
    .await(10, SECONDS);


In this example, the reactive endpoint is defined using Helidon's routing. This allows developers to handle asynchronous operations more efficiently, crucial for building responsive microservices. 

Improved Configuration Management

Helidon 4 introduces enhancements in configuration management, simplifying the process of externalized configuration. 

Java
 
# application.yaml for Helidon 4
server:
  port: 8080


Helidon 4 allows developers to configure their microservices using YAML files, environment variables, or external configuration services. The application.yaml file above demonstrates a straightforward configuration for the server port. 

Integrated Health Checks and Metrics

Helidon 4's integration of health checks and metrics offers a comprehensive solution, providing developers with real-time insights into application health, proactive issue identification, and data-driven decision-making for optimal performance. 

Defining Custom Health Checks to assess specific aspects of their microservices. In the following example, a custom health check is created to verify the responsiveness of an external service

Java
 
HealthSupport.builder()
    .addLiveness(() -> {
        // Custom health check logic
        boolean externalServiceReachable = checkExternalService();
        return HealthCheckResponse.named("external-service-check")
            .state(externalServiceReachable)
            .build();
    })
    .build();


Here, the addLiveness method is used to incorporate a custom health check that evaluates the reachability of an external service. Developers can define various checks tailored to their application's requirements. 

Enabling Metrics for Key Components, such as the web server 

Java
 
MetricsSupport.builder()
    .config(webServerConfig)
    .build();


In this snippet, metrics support is configured for the web server, providing granular insights into its performance metrics. Developers can extend this approach to other components critical to their microservices architecture. 

Exposing Metrics Endpoints, facilitating easy consumption by external monitoring tools. 

Java
 
PrometheusSupport.create()
    .register(webServer);


Here, Prometheus support is created, allowing developers to register the web server for metrics exposure. This integration streamlines the process of collecting and visualizing metrics data.

Simplified Security Configuration 

Security is paramount in microservices, and Helidon 4 streamlines the configuration of security features. 

Java
 
// Security configuration in Helidon 4
Security security = Security.builder()
    .addProvider(JwtProvider.create()) // Add JWT authentication provider
    .addProvider(HttpBasicAuthProvider.create()) // Add HTTP Basic authentication provider
    .build();


In this example, Helidon's Security module is configured to use JWT authentication and HTTP Basic authentication. This simplifies the implementation of security measures in microservices. 

Expanded MicroProfile Rest Client Support 

Microservices often communicate with each other, and Helidon 4 expands its support for MicroProfile Rest Client. 

Java
 
// MicroProfile Rest Client in Helidon 4
@RegisterRestClient
public interface GreetService {
    @GET
    @Path("/greet")
    @Produces(MediaType.TEXT_PLAIN)
    String greet();
}


Here, a MicroProfile Rest Client interface is defined to interact with an /greet endpoint. Helidon 4 simplifies the creation of type-safe REST clients. 

Oracle Cloud Infrastructure (OCI) Integration 

The integration of Helidon 4 with Oracle Cloud Infrastructure represents a pivotal shift in microservices development. OCI, renowned for its scalability, security, and performance, becomes the natural habitat for Helidon 4, empowering developers to harness the full potential of cloud-native development.

Configuring OCI Properties in Helidon 4

Java
 
import io.helidon.config.Config;
import io.helidon.config.ConfigSources;

public class OCIConfigExample {
    public static void main(String[] args) {
        Config config = Config.builder()
                .sources(ConfigSources.classpath("application.yaml"))
                .addSource(ConfigSources.create(OCIConfigSource.class.getName()))
                .build();
        
        String ociPropertyValue = config.get("oci.property", String.class).orElse("default-value");
        System.out.println("OCI Property Value: " + ociPropertyValue);
    }
}


In this example, the OCIConfigSource integrates OCI-specific configuration into the Helidon configuration, allowing developers to access OCI properties seamlessly. 

They are leveraging OCI Identity and Access Management (IAM). OCI IAM plays a crucial role in managing access and permissions. Helidon 4 allows developers to leverage IAM for secure microservices deployment effortlessly. 

Java
 
public class HelidonOCIIntegration {
    public static void main(String[] args) {
        Security security = Security.builder()
                .addProvider(OidcProvider.builder()
                        .identityServerUrl("https://identity.oraclecloud.com/")
                        .clientId("your-client-id")
                        .clientSecret("your-client-secret")
                        .build())
                .build();

        WebSecurity.create(security, webServer -> {
            // Configure security for web server
        });
    }
}


In this example, the Helidon application integrates with OCI's Identity and Access Management through the OIDC provider, allowing developers to enforce secure authentication and authorization in their microservices. 

Deploying Helidon Microservices on OCI

Java
 
public static void main(String[] args) {
	Server.builder()
		.port(8080)
		.start();
}


Streamlined Project Templates 

Getting started with microservices development is made easier with Helidon 4's streamlined project templates. 

Java
 
# Create a new Helidon project with Maven archetype
mvn archetype:generate -DinteractiveMode=false \
    -DarchetypeGroupId=io.helidon.archetypes \
    -DarchetypeArtifactId=helidon-quickstart-mp \
    -DarchetypeVersion=2.0.0 \
    -DgroupId=com.example \
    -DartifactId=myproject \
    -Dpackage=com.example.myproject


The Maven archetype simplifies the creation of a new Helidon project, providing a well-defined structure to kickstart development.

Conclusion

Helidon 4's new features, as demonstrated through real-world examples, showcase the framework's commitment to providing a powerful and developer-friendly environment for microservices development. From MicroProfile compatibility to enhanced support for reactive programming, improved configuration management, and streamlined security configurations, Helidon 4 empowers developers to build scalable and resilient microservices with ease. As the landscape of microservices continues to evolve, Helidon 4 stands out as a versatile and robust framework, ready to meet the challenges of modern application development.

Reactive programming Java (programming language) microservice security Cloud

Opinions expressed by DZone contributors are their own.

Related

  • Jakarta Security and REST in the Cloud: Part 2 Getting to Know the Basics
  • Unlocking the Power of Oracle NoSQL With Quarkus: Seamless Integration for Cloud-Age Applications
  • Keep Your Application Secrets Secret
  • Legacy Code Refactoring: Tips, Steps, and Best Practices

Partner Resources


Comments

ABOUT US

  • About DZone
  • Send feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: