What's new in Vert.x 4.2

Vert.x 4.2 comes with plenty of new exciting features.

Here is an overview of the most important features supported in Vert.x 4.2.

Java 17

Vert.x 4.2 comes with official support of Java 17.

Our CI has been updated to test from our Java 8 baseline to the very recent Java 17 release.

Reactive SQL Clients

Oracle client

The Reactive Oracle Client joins the database clients family!

This client is in tech preview and we are eager to hear any feedback you may have.

Microsoft SQL Server client

Encryption

The Reactive SQL Server Client is able to negotiate the encryption level when a connection is established:

  • no encryption
  • encrypt login packet only
  • encrypt entire connection

Azure SQL Database

Our client is now able to connect to Azure SQL Database servers.

This was made possible thanks to:

MQTT Server V5 support

The MQTT Server has been upgraded to support the version 5 of the protocol partially (the auth message remains to be implemented).

Cassandra Client

The Cassandra Client can trace query execution when Vert.x has tracing enabled.

The client reports the following client spans:

  • Query operation name
  • tags
    • peer.address: list of nodes known to the driver, in the form [127_0_0_1:9042,localhost:9042,myhost_mydomain:9042]
    • span.kind: client
    • db.instance: the keyspace
    • db.statement: the CQL query
    • db.type: cassandra

Web Client enhancements

Our Web Client supports now Oauth2 automated token security management.

WebClient client = WebClient.create(vertx);
OAuth2WebClient oauth2 = OAuth2WebClient.create(
    client,
    OAuth2Auth.create(vertx, new OAuth2Options(/* enter IdP config */)))
 
  // configure the initial credentials (needed to fetch if needed
  // the access_token
  .withCredentials(new TokenCredentials("some.jwt.token"));

Tokens are now fetched or refreshed during the lifecycle of the client.

It also offers an HTTP response caching facility.

WebClient client = WebClient.create(vertx);
WebClient cachingWebClient = CachingWebClient.create(client);

Auth enhancements

Webauthn

Webauthn now supports MDS3. The now “legacy” MDS2 is still available as the service is expected to be running until Nov 2022. In terms of usage, nothing changed, the module can identify the metadata version from the payload and decide how to handle it internally.

OTP

A new module and handler for 2nd factor authentication is now available:

OtpAuthHandler otp = OtpAuthHandler.create(TotpAuth.create();
 
otp
  // the issuer for the application
  .issuer("Vert.x Demo")
  // handle code verification responses
  .verifyUrl("/verify-otp.html")
  // handle registration of authenticators
  .setupRegisterCallback(router.post("/otp/register"))
  // handle verification of authenticators
  .setupCallback(router.post("/otp/verify"));

This module and handler are compatible with google authenticator and similar apps.

OpenAPI

When using OpenAPI and eventbus deployed services, when deploying secure APIs, the HTTP Authorization header is now propagated along with the request all the way with the request on the eventbus. This paves the way to create a Zero Trust foundation for vert.x distributed applications.

Redis Client

Redis client now support REPLICATION mode. This mode is commonly used by cloud providers like Azure and AWS. The client will act just like in a clustered mode, with less overhead as the hosting will perform most of the clustered tasks, not the client.

Redis.createClient(
      vertx,
      new RedisOptions()
        .setType(RedisClientType.REPLICATION)
        .addConnectionString("redis://localhost:7000"))
      .connect()
      .onSuccess(conn -> {
        // this is a replication client.
        // write operations will end up in the master node
        conn.send(Request.cmd(Command.SET).arg("key").arg("value"));
        // and read operations will end up in the replica nodes if available
        conn.send(Request.cmd(Command.GET).arg("key"));
      });

Vert.x Web GraphQL

Context Management

Vert.x Web GraphQL has been upgraded to GraphQL-Java version 17. In this version, the GraphQLContext object becomes the standard to share contextual data between components of a GraphQL Java application (see v17 Release Notes).

Consequently, we have:

  • deprecated the existing context hooks in Vert.x Web GraphQL handlers
  • created new hooks (e.g. GraphQLHandler beforeExecute) for context management

GraphQL over Websockets protocol

The Apollo subscriptions-transport-ws library is not being actively maintained. It is recommended that you use the graphql-ws in your client applications library instead.

For this purpose, Vert.x Web GraphQL supports the GraphQL over Websockets protocol.

For details about it, please read the GraphQL over WebSockets announcement.

Vert.x JUnit 5

By default the thread invoking the test methods is the JUnit thread. The io.vertx.junit5.RunTestOnContext extension can be used to alter this behavior by running test methods on a Vert.x event-loop thread.

Posted on 26 October 2021
in releases
4 min read

Related posts