Eclipse Vert.x 3.6.0 released!

We are pleased to an­nounce the Eclipse Vert.x 3.6.0 re­lease.

As al­ways, the com­mu­nity con­tri­bu­tions have been key in achiev­ing this mile­stone. To all of you who par­tic­i­pated: thank you, you are awe­some!

With­out fur­ther ado, let’s take a look at some of the most ex­cit­ing new fea­tures and en­hance­ments.

Vert.x Cassandra client

In this re­lease we in­tro­duce the Vert.x Cas­san­dra client, an ex­ten­sion for in­ter­a­tion with Apache Cas­san­dra.

The client sup­ports:

  • pre­pared queries
  • batch­ing
  • query stream­ing
  • bulk fetch­ing
  • low level fetch­ing

To give you an idea of how the API usage may looks like, we pro­vide this ex­am­ple:

cassandraClient.queryStream("SELECT my_string_col FROM my_keyspace.my_table where my_key = 'my_value'", queryStream -> {
    if (queryStream.succeeded()) {
    CassandraRowStream stream = queryStream.result();

    // resume stream when queue is ready to accept buffers again
    response.drainHandler(v -> stream.resume());

    stream.handler(row -> {
        String value = row.getString("my_string_col");
        response.write(value);

        // pause row stream when we buffer queue is full
        if (response.writeQueueFull()) {
        stream.pause();
        }
    });

    // end request when we reached end of the stream
    stream.endHandler(end -> response.end());

    } else {
    queryStream.cause().printStackTrace();
    // response with internal server error if we are not able to execute given query
    response
        .setStatusCode(500)
        .end("Unable to execute the query");
    }
});

Vert.x for Kotlin

Vert.x for Kotlin has been up­dated to the very re­cent Kotlin 1.3 (and corou­tines 1.0).

Vert.x 3.5 in­tro­duced a pow­er­ful way to write syn­chro­nous non-​blocking code with Kotlin corou­tines:

val result = awaitResult<ResultSet> { client.queryWithParams("SELECT TITLE FROM MOVIE WHERE ID=?", json { array(id) }, it) };

In this re­lease, awaitResult idiom as ex­ten­sion meth­ods are pro­vided, so now you can di­rectly write:

val result = client.queryWithParamsAwait("SELECT TITLE FROM MOVIE WHERE ID=?", json { array(id) })

Note the Await suf­fix: all Vert.x asyn­chro­nous meth­ods pro­vide now an await­i­fied ex­ten­sion.

Web API gateways

The new Vert.x Web API Ser­vice mod­ule al­lows you to cre­ate Vert.x Web API Con­tract gate­ways.

Web API Service Architecture

@WebApiServiceGen can an­no­tate your ser­vice in­ter­face to han­dle Ope­nAPI 3: Vert.x Web API Ser­vice re­quests:

@WebApiServiceGen
interface TransactionService {

  void getTransactionsList(String from, String to, OperationRequest context, Handler<AsyncResult<OperationResponse>> resultHandler);

  void putTransaction(JsonObject body, OperationRequest context, Handler<AsyncResult<OperationResponse>> resultHandler);
}

The OpenAPI3RouterFactory web router be­comes an API gate­way send­ing re­quests di­rectly to your ser­vices.

These ser­vices are pow­ered by the Vert.x event bus and ben­e­fits from fea­tures like load bal­anc­ing and clus­ter­ing.

Check the com­plete doc­u­men­ta­tion for more de­tails (a tu­to­r­ial post is com­ing soon!)

Web Client

Our beloved We­b­Client is now ca­pa­ble of han­dling client ses­sions. The WebClientSession is a client ex­ten­sion that is very help­ful when you need to man­age cook­ies on the client side.

// The session is created per user
// from now on cookies are handled by the session
WebClientSession session = WebClientSession.create(client);

Cherry on the cake, the web client is now ca­pa­ble of per­form­ing server side re­sponse checks using re­sponse pred­i­cates:

client
  .get(8080, "myserver.mycompany.com", "/some-uri")
  .expect(ResponsePredicate.SC_SUCCESS)
  .expect(ResponsePredicate.JSON)
  .send(result -> { ... });

The server side re­sponse must val­i­date the ex­pec­ta­tions de­fined be­fore send­ing the re­quest in order to make the re­sponse suc­cess­ful, re­liev­ing the user code to per­form these checks man­u­ally. Of course many out of box ex­peca­tions are pro­vided and you can al­ways cre­ate your own to im­ple­ment cus­tom checks.

Use templating everywhere

Tem­plate en­gines can now be used out­side the realm of Vert.x Web. One great use case is to use them to gen­er­ate email con­tent:

TemplateEngine template = ...

template.render(new JsonObject(), "my-template.txt, res -> {
   // Send result with the Vert.x Mail client
});

OpenID Connect Discovery

Oauth2 has been greatly en­hanced to sup­port more of OpenID Con­nect, the most noti­ci­ble is the sup­port of OpenID Connect Discovery 1.0.

What this means for the end user is that, con­fig­u­ra­tion is now a triv­ial task, as it is ”dis­coverd” from the server, e.g.:

OpenIDConnectAuth.discover(vertx,
  new OAuth2ClientOptions()
    .setSite("https://accounts.google.com")
    .setClientID("clientId"),
  res -> {
    if (res.succeeded()) {
      // the setup call succeeded.
      // at this moment your auth is ready to use and
      // google signature keys are loaded so tokens can be decoded and verified.
    } else {
      // the setup failed.
    }
});

If you know your cli­en­tId and your provider server URL (of course), all the re­main­ing en­doints, key sig­na­ture al­go­rithms and JSON Web Keys are “dis­cov­ered” for you and con­fig­ured to the auth provider.

Password Hashing strategy

Vert.x auth com­po­nents now sup­port user de­fined pass­word hash­ing strate­gies, If you’re not happy with the pro­vided im­ple­men­ta­tions: SHA512 or PKDBF2 you can now pro­vide your own strat­egy so it can be used with JDBC or Mongo auth.

The hash ver­i­fi­ca­tion al­go­rithm has been im­proved to be time con­stant, re­gard­less of the re­sult, which pro­tects Vert.x ap­pli­ca­tions from hash tim­ing at­tacks.

Externalized configuration of Vert.x options

Whether you run your Vert.x app with the CLI or as an ex­e­cutable JAR with the Launcher, you can now pro­vide Vert.x op­tions as a com­mand line pa­ra­me­ter:

java -jar my-app.jar -options /path/to/my/file.json

Or with the CLI:

vertx run my-verticle.js -options /path/to/my/file.json

This is par­tic­u­larly use­ful for com­plex clus­tered event-​bus se­tups (en­cryp­tion, pub­lic host vs clus­ter host…).

And more…

Here are some other im­por­tant im­prove­ments you can find in this re­lease:

Finally

The 3.6.0 re­lease notes can be found on the wiki, as well as the list of dep­re­ca­tions and break­ing changes

Docker im­ages are avail­able on Docker Hub.

The Vert.x dis­tri­b­u­tion can be down­loaded on the web­site but is also avail­able from SD­KMan and Home­Brew.

The event bus client using the SockJS bridge is avail­able from:

The re­lease ar­ti­facts have been de­ployed to Maven Cen­tral and you can get the dis­tri­b­u­tion on Bin­tray.

That’s it! Happy cod­ing and see you soon on our user or dev chan­nels.

Next post

The RSS reader tutorial (Step 3)

This is the third installment of our Vert.x Cassandra Client tutorial. We will implement the last RSS endpoint serving a list of articles related to a specific channel.

Read more
Previous post

Eclipse Vert.x 3.5.4

We have just released Vert.x 3.5.4, a bug fix release of Vert.x 3.5.x.

Read more
Related posts

Real-time bidding with Websockets and Vert.x

The expectations of users for interactivity with web applications have changed over the past few years. Users during bidding in auction no longer want to press the refresh button.

Read more

Building services and APIs with AMQP 1.0

Microservices and APIs are everywhere. Everyone talks about them, presentation slides are full of them ... some people are actually even building them.

Read more

Eclipse Vert.x 4 milestone 5 released!

We are extremely pleased to announce the fifth 4.0 milestone release of Eclipse Vert.x. This release aims to provide a reliable distribution of the current development of Vert.x 4.

Read more