Skip to main content

Eclipse Vert.x 3.6.0 released !

We are pleased to announce the Eclipse Vert.x 3.6.0 release.

As always, the community contributions have been key in achieving this milestone. To all of you who participated: thank you, you are awesome!

Without further ado, let’s take a look at some of the most exciting new features and enhancements.

Vert.x Cassandra client

In this release we introduce the Vert.x Cassandra client, an extension for interation with Apache Cassandra.

The client supports:

  • prepared queries
  • batching
  • query streaming
  • bulk fetching
  • low level fetching

To give you an idea of how the API usage may looks like, we provide this example:

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 updated to the very recent Kotlin 1.3 (and coroutines 1.0).

Vert.x 3.5 introduced a powerful way to write synchronous non-blocking code with Kotlin coroutines:

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

In this release, awaitResult idiom as extension methods are provided, so now you can directly write:

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

Note the Await suffix: all Vert.x asynchronous methods provide now an awaitified extension.

Web API gateways

The new Vert.x Web API Service module allows you to create Vert.x Web API Contract gateways.

Web API Service Architecture

@WebApiServiceGen can annotate your service interface to handle OpenAPI 3: Vert.x Web API Service requests:

@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 becomes an API gateway sending requests directly to your services.

These services are powered by the Vert.x event bus and benefits from features like load balancing and clustering.

Check the complete documentation for more details (a tutorial post is coming soon!)

Web Client

Our beloved WebClient is now capable of handling client sessions. The WebClientSession is a client extension that is very helpful when you need to manage cookies 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 capable of performing server side response checks using response predicates:

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

The server side response must validate the expectations defined before sending the request in order to make the response successful, relieving the user code to perform these checks manually. Of course many out of box expecations are provided and you can always create your own to implement custom checks.

Use templating everywhere

Template engines can now be used outside the realm of Vert.x Web. One great use case is to use them to generate email content:

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 enhanced to support more of OpenID Connect, the most noticible is the support of OpenID Connect Discovery 1.0.

What this means for the end user is that, configuration is now a trivial task, as it is “discoverd“ 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 clientId and your provider server URL (of course), all the remaining endoints, key signature algorithms and JSON Web Keys are “discovered” for you and configured to the auth provider.

Password Hashing strategy

Vert.x auth components now support user defined password hashing strategies, If you’re not happy with the provided implementations: SHA512 or PKDBF2 you can now provide your own strategy so it can be used with JDBC or Mongo auth.

The hash verification algorithm has been improved to be time constant, regardless of the result, which protects Vert.x applications from hash timing attacks.

Externalized configuration of Vert.x options

Whether you run your Vert.x app with the CLI or as an executable JAR with the Launcher, you can now provide Vert.x options as a command line parameter:

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 particularly useful for complex clustered event-bus setups (encryption, public host vs cluster host…).

And more…

Here are some other important improvements you can find in this release:

Finally

The 3.6.0 release notes can be found on the wiki, as well as the list of deprecations and breaking changes

Docker images are available on Docker Hub.

The Vert.x distribution can be downloaded on the website but is also available from SDKMan and HomeBrew.

The event bus client using the SockJS bridge is available from:

The release artifacts have been deployed to Maven Central and you can get the distribution on Bintray.

That’s it! Happy coding and see you soon on our user or dev channels.