5

What's new in Vert.x 4.1

 2 years ago
source link: https://vertx.io/blog/whats-new-in-vert-x-4-1/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

What's new in Vert.x 4.1

Vert.x 4.1 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.1.

Reactive Microsoft SQL Server Client

The Re­ac­tive Mi­crosoft SQL Server Client joins the data­base clients fam­ily!

In this first re­lease, sev­eral com­mon data types are sup­ported, as well as pre­pared state­ments and trans­ac­tions.

Vert.x HTTP Proxy

It is very easy to write an HTTP proxy with Vert.x, yet there are a lot of things that prox­ies must do.

Vert.x HTTP Proxy is a new com­po­nent of the stack that aims to make it easy to write prox­ies.

You can cre­ate a proxy as fol­lows:

proxyServer.requestHandler(
       HttpProxy.reverseProxy(vertx.createHttpClient())
       .origin(7070, "localhost"))
   .listen(8080);

The proxy can also dy­nam­i­cally re­solve the ori­gin (i.e the prox­ied server):

HttpProxy proxy = HttpProxy.reverseProxy(proxyClient).originSelector(
  address -> resolveOrigin(address)
);

Vert.x Web Proxy in­te­grates the proxy with Vert.x Web.

This com­po­nent is in tech pre­view and will re­ceive more fea­tures over time.

RxJava 3

Vert.x has been sup­port­ing Rx­Java for many years, the Rx­Java 3 sup­port has landed in 4.1

The rx­i­fied API works like pre­vi­ous ver­sions, how­ever reg­u­lar meth­ods are ex­posed with Rx­Java types in­stead of call­backs since Vert.x 4 async model is based on fu­tures.

server.requestHandler(req -> {
  HttpServerResponse resp = req.respone();
  resp.setChunked(true);

  // No need to subscribe to the completable
  Completable c1 = resp.write("1");

  // Write result is cached, this will send
  // 1
  c1.subscribe();
  c1.subscribe();

  // The Rxified API however requires subscription to trigger the call
  Completable c2 = resp.rxWrite("2");

  // Write is subscription based, this will send
  // 2
  // 2
  c2.subscribe();
  c2.subscribe();
});

Open Telemetry support

Open Teleme­try trac­ing is a new and no­tice­able trac­ing in­te­gra­tion avail­able in 4.1.

Service proxy with futures

Vert.x 4 pro­vides a future-​first API. How­ever, ser­vice prox­ies can only be de­clared with call­backs.

We ad­dressed this issue in Vert.x 4.1 and you can now write ser­vice prox­ies with fu­tures. The only change you need is to de­clare the fu­ture usage in the Code­gen mod­ule de­c­la­ra­tion.

Vertx-Web

In this re­lease, we im­proved the log­ging han­dler to en­able cus­tom log­ging for­mats.

The OAuth2 han­dler now fol­lows the OIDC stan­dard by val­i­dat­ing the re­quested scopes are present in the OAuth2 re­sponse. A new APIKEY han­dler was added to sup­port more se­cu­rity use cases, and it is now pos­si­ble to write cus­tom authn han­dlers with­out re­quir­ing in­ter­nal classes.

The API ctx.json() now fol­lows the IANA con­tent type stan­dard.

Vertx-Web OpenAPI

A lot of com­mu­nity dis­cus­sions and work has been done to im­prove the se­cu­rity han­dling of Ope­nAPI in Vert.x. We now sup­port all kinds of se­cu­rity de­scribed in Ope­nAPI 3.0, OpenId, OAuth2, API-​Key, HTTP.

The new API also al­lows for fetch­ing the se­cu­rity con­fig­u­ra­tion from the doc­u­ment it­self, rather than hav­ing it double-​configured in the doc­u­ment and in the code.

Vertx-Auth

In the Vert.x auth mod­ule, sup­port for EdDSA was added to the JOSE/COSE code. This means that we can now use those al­go­rithms in JWT/OAuth2/OIDC/FIDO2. The sup­port re­lies only on the pro­vided JDK which means that users will need to use JDK 15 or above to be able to use those al­go­rithms.

In the JOSE code, im­prove­ments were made to cor­rectly fol­low the use value of a JWK and more tests were added to ver­ify that we in­terop prop­erly with to­kens gen­er­ated by other li­braries.

Fi­nally, in FIDO2/Webauthn we fol­low the rec­om­men­da­tion of stor­ing the at­tes­ta­tion cer­tifi­cates, which al­lows of­fline val­i­da­tion of de­vices. This is a util­ity that al­lows you to check if to­kens have been com­pro­mised and dis­able their fu­ture use at the RP.

General pool improvements

Vert.x in­ter­nal pool has been im­proved to gain more flex­i­bil­ity with new fea­tures such as

  • mul­ti­ple event loops per pool
  • waiter can­cel­la­tion
  • lock free im­ple­men­ta­tion
  • con­nec­tion se­lec­tion strat­egy

In ad­di­tion, the in­ter­nal pool is now used by the Vert.x SQL Client and Vert.x Mail Clients.

Web Session Storage with Infinispan

Vert.x Web ses­sion stor­age is plug­gable. In this ver­sion, a new ses­sion store with In­fin­is­pan in-​memory data grid is avail­able.

It is im­ple­mented on top of the In­fin­is­pan client so it can be used with ei­ther stand­alone or clus­tered Vert.x ap­pli­ca­tions.

If you want to get started, don’t miss the Web Ses­sion Stor­age with In­fin­is­pan Client how-​to.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK