Chapter 7. Changes in protocols
This section explains the changes in networking protocols.
7.1. Changes in Eclipse Vert.x gRPC Copy linkLink copied to clipboard!
The following section describes the changes in Eclipse Vert.x gRPC.
7.1.1. New gRPC compiler plugin Copy linkLink copied to clipboard!
In Eclipse Vert.x 4, the module protoc-gen-grpc-java
is no longer available. This module was a fork of the official gRPC compiler. In earlier releases of Eclipse Vert.x, you had to work with this fork. This fork is maintained by the Eclipse project. Working with the fork was complex.
In previous releases, to work with gRPC, the following details were added to pom.xml
file.
In Eclipse Vert.x 4, a new gRPC compiler plugin is available. This plugin uses the official gRPC compiler instead of the fork. To work with the new gRPC plugin, add the following details to pom.xml
file.
7.1.2. Migrating the generated code Copy linkLink copied to clipboard!
In Eclipse Vert.x 4, the new compiler is used. When the new gRPC plugin is used, the generated code is not written in the same source file. This is because the compiler does not allow custom code generation on its base class. The plugins must generate a new class with a different name to save the code.
In earlier releases of Eclipse Vert.x, the older gRPC plugin would write the generated code in the same source file.
For example, if you have the following descriptor:
service Greeter { rpc SayHello (HelloRequest) returns (HelloReply) {} }
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
In Eclipse Vert.x 3.x, the code would be generated in the GreeterGrpc
class.
// 3.x GreeterGrpc.GreeterVertxImplBase service = new GreeterGrpc.GreeterVertxImplBase() { ... }
// 3.x
GreeterGrpc.GreeterVertxImplBase service =
new GreeterGrpc.GreeterVertxImplBase() {
...
}
In Eclipse Vert.x 4, the code is generated in the VertxGreeterGrpc
class.
// 4.x VertxGreeterGrpc.GreeterVertxImplBase service = new VertxGreeterGrpc.GreeterVertxImplBase() { ... }
// 4.x
VertxGreeterGrpc.GreeterVertxImplBase service =
new VertxGreeterGrpc.GreeterVertxImplBase() {
...
}
7.1.3. gRPC APIs support futures Copy linkLink copied to clipboard!
In Eclipse Vert.x 4, the gRPC APIs support futures. The gRPC plugin generates promisified APIs. These APIs use the standard Eclipse Vert.x input and output arguments, which makes it easier to create standard Eclipse Vert.x applications.
The following example shows the use of promise in Eclipse Vert.x 3.x.
The following example shows the use of futures in Eclipse Vert.x 4.
7.2. Changes in Eclipse Vert.x MQTT Copy linkLink copied to clipboard!
The following section describes the changes in Eclipse Vert.x MQTT.
7.2.1. Some fluent methods in MQTT clients return future Copy linkLink copied to clipboard!
Some fluent methods in MqttClient
class return Future
instead of being fluent. For example, methods such as, MqttClient.connect()
, MqttClient.disconnect()
, MqttClient.publish()
return future in Eclipse Vert.x 4.
The following example shows the use of publish()
method in Eclipse Vert.x 3.x releases.
client .publish("hello", Buffer.buffer("hello"), MqttQoS.EXACTLY_ONCE, false, false) .publish("hello", Buffer.buffer("hello"), MqttQoS.AT_LEAST_ONCE, false, false);
client
.publish("hello", Buffer.buffer("hello"), MqttQoS.EXACTLY_ONCE, false, false)
.publish("hello", Buffer.buffer("hello"), MqttQoS.AT_LEAST_ONCE, false, false);
The following example shows the use of publish()
method in Eclipse Vert.x 4 release.
client.publish("hello", Buffer.buffer("hello"), MqttQoS.EXACTLY_ONCE, false, false); client.publish("hello", Buffer.buffer("hello"), MqttQoS.AT_LEAST_ONCE, false, false);
client.publish("hello", Buffer.buffer("hello"), MqttQoS.EXACTLY_ONCE, false, false);
client.publish("hello", Buffer.buffer("hello"), MqttQoS.AT_LEAST_ONCE, false, false);
7.2.2. MqttWill messages return buffer Copy linkLink copied to clipboard!
The MqttWill
data object wraps a string message as an Eclipse Vert.x buffer instead of a byte array.
7.2.3. Removed the deprecated MqttWill and authorization methods from MQTT Copy linkLink copied to clipboard!
The following MQTT methods have been removed:
Removed methods | Replacing methods |
|
|
|
|
|
|
|
|
|
|
|
|
7.3. Changes in Eclipse Vert.x Service Proxy Copy linkLink copied to clipboard!
The following section describes the changes in service proxy.
7.3.1. Using service proxy code generator Copy linkLink copied to clipboard!
The ServiceProxyProcessor
class has been removed.
To use the service proxy code generator, you must import vertx-codegen
with processor classifier in your classpath:
Service proxy reuses io.vertx.codegen.CodeGenProcessor
from vertx-codegen
to start the code generation of service proxy and handler.