What's new in Vert.x 4.2

Vert.x 4.2 comes with plenty of new ex­cit­ing fea­tures.

Here is an overview of the most im­por­tant fea­tures sup­ported in Vert.x 4.2.

Java 17

Vert.x 4.2 comes with of­fi­cial sup­port of Java 17.

Our CI has been up­dated to test from our Java 8 base­line to the very re­cent Java 17 re­lease.

Reactive SQL Clients

Oracle client

The Re­ac­tive Or­a­cle Client joins the data­base clients fam­ily!

This client is in tech pre­view and we are eager to hear any feed­back you may have.

Microsoft SQL Server client

Encryption

The Re­ac­tive SQL Server Client is able to ne­go­ti­ate the en­cryp­tion level when a con­nec­tion is es­tab­lished:

  • no en­cryp­tion
  • en­crypt login packet only
  • en­crypt en­tire con­nec­tion

Azure SQL Database

Our client is now able to con­nect to Azure SQL Data­base servers.

This was made pos­si­ble thanks to:

MQTT Server V5 support

The MQTT Server has been up­graded to sup­port the ver­sion 5 of the pro­to­col par­tially (the auth mes­sage re­mains to be im­ple­mented).

Cassandra Client

The Cas­san­dra Client can trace query ex­e­cu­tion when Vert.x has trac­ing en­abled.

The client re­ports the fol­low­ing client spans:

  • Query op­er­a­tion name
  • tags
    • peer.address: list of nodes known to the dri­ver, in the form [127_0_0_1:9042,localhost:9042,myhost_mydomain:9042]
    • span.kind: client
    • db.instance: the key­space
    • db.statement: the CQL query
    • db.type: cassandra

Web Client enhancements

Our Web Client sup­ports now Oauth2 au­to­mated token se­cu­rity man­age­ment.

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"));

To­kens are now fetched or re­freshed dur­ing the life­cy­cle of the client.

It also of­fers an HTTP re­sponse caching fa­cil­ity.

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

Auth enhancements

Webauthn

We­bau­thn now sup­ports MDS3. The now “legacy” MDS2 is still avail­able as the ser­vice is ex­pected to be run­ning until Nov 2022. In terms of usage, noth­ing changed, the mod­ule can iden­tify the meta­data ver­sion from the pay­load and de­cide how to han­dle it in­ter­nally.

OTP

A new mod­ule and han­dler for 2nd fac­tor au­then­ti­ca­tion is now avail­able:

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 mod­ule and han­dler are com­pat­i­ble with google au­then­ti­ca­tor and sim­i­lar apps.

OpenAPI

When using Ope­nAPI and event­bus de­ployed ser­vices, when de­ploy­ing se­cure APIs, the HTTP Authorization header is now prop­a­gated along with the re­quest all the way with the re­quest on the event­bus. This paves the way to cre­ate a Zero Trust foun­da­tion for vert.x dis­trib­uted ap­pli­ca­tions.

Redis Client

Redis client now sup­port REPLICATION mode. This mode is com­monly used by cloud providers like Azure and AWS. The client will act just like in a clus­tered mode, with less over­head as the host­ing will per­form most of the clus­tered 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 up­graded to GraphQL-​Java ver­sion 17. In this ver­sion, the GraphQLContext ob­ject be­comes the stan­dard to share con­tex­tual data be­tween com­po­nents of a GraphQL Java ap­pli­ca­tion (see v17 Re­lease Notes).

Con­se­quently, we have:

GraphQL over Websockets protocol

The Apollo subscriptions-transport-ws li­brary is not being ac­tively main­tained. It is rec­om­mended that you use the graphql-ws in your client ap­pli­ca­tions li­brary in­stead.

For this pur­pose, Vert.x Web GraphQL sup­ports the GraphQL over Web­sock­ets pro­to­col.

For de­tails about it, please read the GraphQL over Web­Sock­ets an­nounce­ment.

Vert.x JUnit 5

By de­fault the thread in­vok­ing the test meth­ods is the JUnit thread. The io.vertx.junit5.RunTestOnContext ex­ten­sion can be used to alter this be­hav­ior by run­ning test meth­ods on a Vert.x event-​loop thread.

Previous post

Migrate from Vert.x 3 to Vert.x 4

We provide a clear and well-documented migration path from Vert.x 3.9 to Vert.x 4. Existing users will feel at home with the new version.

Read more
Related posts

Things to keep in mind concerning CSRF attacks

Eclipse Vert.x like most frameworks provides an anti-CSRF defense. However, no framework can prevent all attack vectors that exist in the web. Therefore, developers need to be aware of some dangers and common attack vectors concerning CSRF defenses.

Read more

Unit and Integration Tests

Let’s refresh our mind about what we developed so far in the introduction to vert.x series. We forgot an important task. We didn’t test the API.

Read more

Eclipse Vert.x 3.7.0 released!

We are extremely pleased to announce that the Eclipse Vert.x version 3.7.0 has been released.

Read more