Getting started with Quarkus 3

This article introduces some of the new features of the upcoming Quarkus 3 release which is, at the time of writing, in Alpha state. We will cover the main highlights and some tools you can use to upgrade existing Quarkus applications.

Quarkus 3 highlights

Firstly, let’s discuss Quarkus 3 main highlights:

  1. Jakarta EE 10 API: the new major version of Quarkus will align to the Jakarta EE 10 standard, which means, besides new functionalities, also the new ‘jakarta’ namespace for your applications
  2. Microprofile 6: the new Microprofile major version that augments the platform with cloud-native APIs for developing applications.
  3. HTTP/3 support: HTTP/3 is the latest version of the HTTP protocol, which is based on the QUIC protocol, which aims to improve the performance and security of HTTP by reducing latency and providing encryption by default.
  4. io_uring: io_uring is a Linux kernel system call interface that allows for high-performance asynchronous input/output operations. It provides a way for applications to perform I/O operations in a more efficient and scalable way by eliminating the need for threads and context switches.
  5. Virtual threads (aka Loom) and Structured Concurrency Support: Virtual threads is a new feature in Java that allows for the creation of lightweight threads that can be scheduled by the JVM. This feature aims to improve the scalability and performance of Java applications by reducing the overhead of creating and managing threads.
  6. java.util.concurrent.Flow API: The Flow API is a new feature in Java that provides a reactive programming model for building asynchronous, non-blocking applications. It allows developers to work with streams of data and provides a way to handle backpressure and flow control. This feature aims to make it easier to build high-performance, scalable applications by providing a more efficient and flexible way of handling data.
  7. Tooling updates: To simplify the upgrade to Quarkus 3, you will be able to use a set of tools. In this article, we will show an example OpenWrite tool to upgrade an existing Quarkus 2 application.

An example Quarkus 3 application

To get started quickly, you can use the Quarkus initializer which is available at: https://code.quarkus.io/

As you can see, the online initializer already features the Alpha version of Quarkus 3:

quarkus 3 tutorial

Besides, you can also generate a Quarkus 3 application from the CLI by adding the –stream option. For example:

quarkus create app --stream=3.0

Then, after we generate the project artifact, we can check that the jakarta namespace is in place, for example in a REST Endpoint:

package org.acme;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

@Path("/hello")
public class GreetingResource {

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
        return "Hello from RESTEasy Reactive";
    }
}

Overall, the project object module does not change significantly from version 2. The main difference will be just the quarkus.platform.version :

<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.0.0.Alpha2</quarkus.platform.version>

You can try some new cool features such as Virtual Threads. For example, add to your Endpoint which includes the @io.smallrye.common.annotation.RunOnVirtualThread annotation:

@GET
@RunOnVirtualThread
public List<City> getPersons() {
        return Arrays.asList(new City("Buenos Aires"), new City("Córdoba"), new City("La Plata"));
}

The above annotation indicates that the (blocking) method should be invoked on a virtual thread instead of a regular (OS) worker thread.

Finally, to be able to build the above code, you will need to use JDK19 which provides support for Virtual threads in the JVM:

<plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${compiler-plugin.version}</version>
        <configuration>
          <source>19</source>
          <target>19</target>
          <compilerArgs>
            <arg>--enable-preview</arg>
          </compilerArgs>
          <jvmArgs>--enable-preview --add-opens java.base/java.lang=ALL-UNNAMED</jvmArgs>
        </configuration>
</plugin>

Tooling to migrate existing Quarkus application

We will finish our overview with some hints on how to migrate a Quarkus 2 application with one of the available tools from OpenWire. For example, we will migrate a Quarkus-Hibernate application from this article: Getting started with Quarkus and Hibernate

Note: This section is a work-in progress area. However, there are already some options to migrate your current Quarkus 2 application. For example, you can use the io.quarkus.openrewrite.Quarkus3 OpenWire recipe with Maven as follows:

mvn org.openrewrite.maven:rewrite-maven-plugin:4.36.0:run    -Drewrite.configLocation=quarkus3.yml    -DactiveRecipes=io.quarkus.openrewrite.Quarkus3

You will see from the Console output the changes in our project files:

[WARNING] Changes have been made to pom.xml by:
[WARNING]     io.quarkus.openrewrite.Quarkus3
[WARNING]         org.openrewrite.maven.ChangePropertyValue: {key=quarkus.platform.version, newValue=3.0.0.Alpha2}
[WARNING] Changes have been made to src/main/java/org/acme/Customer.java by:
[WARNING]     io.quarkus.openrewrite.Quarkus3
[WARNING]         org.openrewrite.java.migrate.JavaxMigrationToJakarta
[WARNING]             org.openrewrite.java.migrate.JavaxPersistenceToJakartaPersistence
[WARNING]                 org.openrewrite.java.ChangePackage: {oldPackageName=javax.persistence, newPackageName=jakarta.persistence, recursive=true}
[WARNING] Changes have been made to src/main/java/org/acme/ExampleResource.java by:
[WARNING]     io.quarkus.openrewrite.Quarkus3
[WARNING]         org.openrewrite.java.migrate.JavaxMigrationToJakarta
[WARNING]             org.openrewrite.java.migrate.JavaxInjectMigrationToJakartaInject
[WARNING]                 org.openrewrite.java.ChangePackage: {oldPackageName=javax.inject, newPackageName=jakarta.inject, recursive=true}
[WARNING]             org.openrewrite.java.migrate.JavaxPersistenceToJakartaPersistence
[WARNING]                 org.openrewrite.java.ChangePackage: {oldPackageName=javax.persistence, newPackageName=jakarta.persistence, recursive=true}
[WARNING]             org.openrewrite.java.migrate.JavaxTransactionMigrationToJakartaTransaction
[WARNING]                 org.openrewrite.java.ChangePackage: {oldPackageName=javax.transaction, newPackageName=jakarta.transaction, recursive=true}
[WARNING]             org.openrewrite.java.migrate.JavaxWsToJakartaWs
[WARNING]                 org.openrewrite.java.ChangePackage: {oldPackageName=javax.ws, newPackageName=jakarta.ws, recursive=true}

Besides, in the output file, quarkus3.yml, you will find a log of all migration steps.

One thing worth mentioning is that the current Alpha release of Quarkus still targets Hibernate 5.6, therefore at the time of writing, you cannot still use the full Hibernate 6 features:

mvn dependency:tree | grep hibernate
[INFO] ---------------------< org.acme:quarkus-hibernate >---------------------
[INFO] Building quarkus-hibernate 2.15
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ quarkus-hibernate ---
[INFO] org.acme:quarkus-hibernate:jar:2.15
[INFO] +- io.quarkus:quarkus-hibernate-orm:jar:3.0.0.Alpha2:compile
[INFO] |  +- org.hibernate:hibernate-core-jakarta:jar:5.6.14.Final:compile

Then, run the application:

mvn install quarkus:dev

Finally, you can enjoy the updated dev-ui which is available at: http://localhost:8080/q/dev/

quarkus 3 tutorial

Conclusion

This article is an overview of the upcoming Quarkus 3 major release. There are several exciting highlights in the new Quarkus release. Stay tuned for updates!

Found the article helpful? if so please follow us on Socials