Building Apps with Helidon & MicroProfile

Implementing a MicroProfile application with JAX-RS, CDI, Metrics, Health, Fault Tolerance, Config from "Scratch" and on Helidon:

Micronaut, MicroProfile, Micronaut Data and Helidon

A code-driven introduction to Micronaut, Micronaut support for MicroProfile, and using Micronaut data with Helidon:

From Competitive Gaming to Java EE API Mavenization--an airhacks.fm podcast

Subscribe to airhacks.fm podcast via: spotify| iTunes| RSS

The #128 airhacks.fm episode with Romain Grecourt (@@rgrecourt) about:
competitive gaming, Java, Glassfish, Maven and Java EE API packaging
is available for

How KumuluzEE Happened--an airhacks.fm podcast

Subscribe to airhacks.fm podcast via: spotify| iTunes| RSS

The #127 airhacks.fm episode with Jan Meznarič (jmezna) about:
"Java microservices, drools, jbpm, GlassFish, MicroProfile, Java EE, FatJARs, exploded JARs and layered JARs, cloud native apps, metrics, configuration, blockchain, peer to peer service updates and how KumuluzEE happened"
is available for

2021: Familiar APIs on Kickass Runtimes--WeAreDevelopers Conference Session

"Java's JAX-RS, DI, JPA, Metrics, Fault Tolerance, Configuration, cloud-readiness combined with minimal start times, high performance, and Go-like feel. ...and this without a dependency on a particular framework, vendor, or library. In this session, I will implement a next-generation Java backend from scratch and explain the magic on-the-fly. Java SE, reactive APIs, Helidon, Quarkus, GraalVM, MicroProfile, and a bit of Jakarta EE included."

Micronaut with JAX-RS, Dependency Injection (JSR-330)--a touch of MicroProfile

micronaut.io supports JAX-RS, Bean Validation and JSR 330: Dependency Injection for Java compatible Dependency Injection and so a MicroProfile subset:

Quarkus, Health, Metrics,OpenAPI: Moved Permanently (301)

Quarkus release 1.11.0 (January 20, 2021) introduced the Dev UI /q/dev. To avoid conflicts, all non-application endpoints (e.g. /health, /metrics) were moved to the new root /q.

Now, the health endpoint is available under: /q/health and metrics are available under /q/metrics

Quarkus automatically redirects the non-application endpoints to the new location:


> curl -i localhost:8080/health
HTTP/1.1 301 Moved Permanently
location: http://localhost:8080/q/health    
and

> curl -i localhost:8080/metrics
HTTP/1.1 301 Moved Permanently
location: http://localhost:8080/q/metrics    

I'm using MicroProfile metrics after torture tests for threshold verification. The release +1.11.* broke the asserts, because JAX-RS / MicroProfile REST client didn't follow the redirects.

Starting with the release: 1.11.2+, also the health endpoint was moved to the new location. Kubernetes expects http status codes: 200-400, so 301 is still considered as 'healthy'.

However: in kubernetes-like environments, the developer may be in charge to specify the health command. Then 301 (redirect) might be problematic.

The /q prefix can be removed with the following property:


quarkus.http.non-application-root-path=/    

The endpoints are defined in the microprofile health and microprofile metrics specifications.

Seems like Quarkus is the first microprofile runtime which moved the endpoints to a different location.

See also related issue: MicroProfile Metrics, Health, OpenAPI URI changed #15030

JavaFX Everywhere ...also in App Stores--an airhacks.fm podcast

Subscribe to airhacks.fm podcast via: spotify| iTunes| RSS

The #126 airhacks.fm episode with Johan Vos (@johanvos) about:
killer JavaFX features, building JavaFX applications in Java / GraalVM, using hardware sensors on mobile devices, building Java FX / Web Components hybrids, and deploying them to all devices, also iOS and Google app stores
is available for

JPA Audits, Transactions, Lazy Loading, Table Naming, MicroProfile Config and Metrics, HTTP Patch--or 83rd airhacks.tv

The 83rd airhacks.tv episode covering the following topics:

"JPA audits, transactions and lazy loading, table naming conventions, schema migrations in CI, MicroProfile config refresh, MicroProfile metrics and @Gauge, JPA entities, HTTP Patch and partial updates"

...is available:

Any questions left? Ask now: https://gist.github.com/AdamBien/d71bc0e6f05c1b8a4ad50ab7d1c2d951 and get the answers at the next airhacks.tv.

Serializing a Collection of Java Records into a JSON Array

A collection (Set) of Java Record instances:


public record Link(String text, String uri) {}

can be serialized with JSON-B into a JSON array:


import org.junit.jupiter.api.Test;
import java.util.Set;
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;

public class JSONBTest {

    @Test
    public void serialize() {
        var links = Set.of(new Link("json-b", "http://json-b.net"),
                            new Link("jakarta ee", "https://jakarta.ee"),
                            new Link("microprofile", "https://microprofile.io"));
        Jsonb jsonb = JsonbBuilder.create();
        var jsonArray = jsonb.toJson(links);
        System.out.println(jsonArray);
    }
}

The code above generates the following output:

[{"text":"jakarta ee","uri":"https://jakarta.ee"},{"text":"microprofile","uri":"https://microprofile.io"},{"text":"json-b","uri":"http://json-b.net"}]

Tested with Apache Johnzon:


<dependency>
    <groupId>org.apache.geronimo.specs</groupId>
    <artifactId>geronimo-jsonb_1.0_spec</artifactId>
    <version>1.4</version>
</dependency>
<dependency>
    <groupId>org.apache.geronimo.specs</groupId>
    <artifactId>geronimo-json_1.1_spec</artifactId>
    <version>1.5</version>
</dependency>
<dependency>
    <groupId>org.apache.johnzon</groupId>
    <artifactId>johnzon-jsonb</artifactId>
    <version>1.2.10</version>
</dependency>    

Online Workshops
...the last 150 posts
...the last 10 comments
License