Vert.x 3.5.0.Beta1

It’s summer time and we have just released Vert.x 3.5.0.Beta1!

Let’s go RxJava2

First and foremost this release delivers the RxJava2 API with support of its full range of types.

In addition of Single, Rxified APIs expose 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"));

RxJava augments Vert.x streams with a toObservable() method, RxJava2 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 different between Flowable and Observable ? the former handles back-pressure, i.e the subscriber can control the flow of items and the later can not!!!

You can read the documentation in the beta section of the docs or go straight to the examples

MQTT Client

In Vert.x 3.4 we added the MQTT server, 3.5 completes 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 examples here

Auth handler chaining

There are times when you want to support multiple authN/authZ mechanisms in a single application.

Vert.x Web supports auth handlers chaining

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 provides

  • Vert.x Config stores for Vault and Consul
  • Upgrade to Hazelcast 3.8.2

Use it!

You can use and consume it in your projects from Maven or Gradle as usual with the version 3.5.0.Beta1 or read

You can also download various binaries from Maven Central:

as usual feedback is very important to us and one goal of this beta release is to let the community provide early feedback!

The final is expected at the beginning of October.

Enjoy

Posted on 10 August 2017
in releases
2 min read

Related posts