Vert.x 3.5.0.Beta1

It’s sum­mer time and we have just re­leased Vert.x 3.5.0.Beta1!

Let’s go RxJava2

First and fore­most this re­lease de­liv­ers the Rx­Java2 API with sup­port of its full range of types.

In ad­di­tion of Single, Rx­i­fied APIs ex­pose also theCompletable and Maybe types

// expose Handler<AsyncResult<Void>>
Completable completable = server.rxClose();

completable.subscribe(() -> System.out.println("closed"));

// expose Handler<AsyncResult<String>> where the result can be null
Maybe<String> ipAddress = dnsClient.rxLookup("www.google.com");
ipAddress.subscribe(
  value -> System.out.println("resolved to " + value),
  err -> err.printStackTrace(),
  () -> System.out.println("does not resolve"));

Rx­Java aug­ments Vert.x streams with a toObservable() method, Rx­Java2 adds the toFlowable() method:

// Flowable<Buffer> maps to a ReadStream<Buffer>
// back-pressured stream
Flowable<Buffer> flowable = asyncFile.toFlowable();

// but we still can get an Observable<Buffer>
// non back-pressured stream
Observable<Buffer> flowable = asyncFile.toObservable();

What’s so dif­fer­ent be­tween Flowable and Observable ? the for­mer han­dles back-​pressure, i.e the sub­scriber can con­trol the flow of items and the later can not!!!

You can read the doc­u­men­ta­tion in the beta sec­tion of the docs or go straight to the ex­am­ples

MQTT Client

In Vert.x 3.4 we added the MQTT server, 3.5 com­pletes the MQTT story with the MQTT client:

MqttClient mqttClient = MqttClient.create(vertx,
   new MqttClientOptions()
     .setPort(BROKER_PORT)
     .setHost(BROKER_HOST)).connect(ar ->
  if (ar.succeeded()) {
    System.out.println("Connected to a server");

    mqttClient.publish(
      MQTT_TOPIC,
      Buffer.buffer(MQTT_MESSAGE),
      MqttQoS.AT_MOST_ONCE,
      false,
      false,
      s -> mqttClient.disconnect(d -> System.out.println("Disconnected from server")));
  } else {
    System.out.println("Failed to connect to a server");
    ar.cause().printStackTrace();
  }
});

You can find MQTT client and server ex­am­ples here

Auth handler chaining

There are times when you want to sup­port mul­ti­ple authN/authZ mech­a­nisms in a sin­gle ap­pli­ca­tion.

Vert.x Web sup­ports auth han­dlers chain­ing

ChainAuthHandler chain = ChainAuthHandler.create();

// add http basic auth handler to the chain
chain.append(BasicAuthHandler.create(provider));

// add form redirect auth handler to the chain
chain.append(RedirectAuthHandler.create(provider));

// secure your route
router.route("/secure/resource").handler(chain);

// your app
router.route("/secure/resource").handler(ctx -> {
  // do something...
});

Finally

This beta also pro­vides

  • Vert.x Con­fig stores for Vault and Con­sul
  • Up­grade to Hazel­cast 3.8.2

Use it!

You can use and con­sume it in your projects from Maven or Gra­dle as usual with the ver­sion 3.5.0.Beta1 or read

You can also down­load var­i­ous bi­na­ries from Maven Cen­tral:

as usual feed­back is very im­por­tant to us and one goal of this beta re­lease is to let the com­mu­nity pro­vide early feed­back!

The final is ex­pected at the be­gin­ning of Oc­to­ber.

Enjoy

Next post

Introducing Vert.x MQTT client

In this article, we will see how to set up the new Vert.x MQTT client. An example project is available on GitHub.

Read more
Previous post

OpenAPI (fka Swagger) 3 support in Eclipse Vert.x now in test stage!

As GSoC 2017's student, I'm working on an embedded support to OpenAPI 3 standard inside Eclipse Vert.x framework. Now, after a lot of work, you can try it!

Read more
Related posts

Some Rest with Vert.x

This post is part of the Introduction to Vert.x series. Let’s go a bit further this time and develop a CRUD-ish application

Read more

Combine vert.x and mongo to build a giant

This blog post is part of the introduction to Vert.x series. We are now going to replace this JDBC client by the vertx-mongo-client, and thus connect to a Mongo database.

Read more

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