RxJava2
首先,此版本提供了 RxJava2 API,支持其全系列类型。
除了 Single,Rxified API 还有 Completable 和 Maybe 类型[code]// expose Handler
completable.subscribe(() -> System.out.println("closed"));
// expose Handler
ipAddress.subscribe(
value -> System.out.println("resolved to " + value),
err -> err.printStackTrace(),
() -> System.out.println("does not resolve"));[/code]RxJava 使用 toObservable() 方法来扩展 Vert.x 流,RxJava2 添加了 toFlowable() 方法:[code]// Flowable maps to a ReadStream
MQTT Client
在 Vert.x 3.4 中,我们添加了 MQTT 服务器,3.5 使用 MQTT 客户端完成 MQTT 代理:[code]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();
}
});[/code]更新内容:
http://vertx.io/blog/vert-x-3-5-0-beta1/
下载地址:
http://vertx.io/download/
软件详情:https://github.com/vert-x3/vertx-examples/tree/3.5.0.beta1/mqtt-examples
来自:开源中国社区

