Reputation: 431
I have quick question - did anyone tried to run both - Vert.x 2 and Vert.x 3 applications in a cluster, communicating over EventBus?
Theoretically it should be possible but has anyone done it?;)
Cheers, Michał
Upvotes: 4
Views: 1105
Reputation: 5801
For the 3.3 release Vert.x is adding a new module to the 2.x series. This new component is mod-eventbus3-bridge-client
.
The idea is that you can deploy this module along your existing 2.x application and it will bridge between the eventbus 2.x and eventbus 3.x.
You can see the code at: https://github.com/vert-x/mod-eventbus3-bridge-client/tree/initial-work
So in Vert.x3 you would need to do:
public class Example {
public static void main(String[] args) {
Vertx vertx = Vertx.vertx();
TcpEventBusBridge bridge = TcpEventBusBridge.create(
vertx,
new BridgeOptions()
.addInboundPermitted(new PermittedOptions())
.addOutboundPermitted(new PermittedOptions()));
bridge.listen(7000, res -> {
// example: vertx3 send a message to vertx2
vertx.eventBus().send("send3", new JsonObject().put("msg", "hello send"));
});
}
}
And on Vert.x2 you would do the reverse:
public class Example extends Verticle {
@Override
public void start() {
final EventBus3 eb = new EventBus3(vertx, getContainer().config(), new Handler<Void>() {
@Override
public void handle(Void done) {
// case #1 vertx3 send a message to vertx2
eb.registerHandler("send3", new Handler<BridgeMessage>() {
@Override
public void handle(BridgeMessage msg) {
System.out.println(msg.body());
}
});
}
});
eb.exceptionHandler(new Handler<Throwable>() {
@Override
public void handle(Throwable throwable) {
throwable.printStackTrace();
}
});
}
}
Upvotes: 3
Reputation: 13
I have tried both Vert.x2 and Vert.x3 EventBus in cluster. But not at the same time. Vert.x2 required jdk 1.7 and Vert.x3 required jdk 1.8 or higher. I tried to run Vert.x2 in jdk 1.8 but that wasn't succeed.
thus, I think running both Vert.x2 and Vert.x3 applications in a cluster not possible.
Upvotes: -1
Reputation: 16354
I'm much appreciate the question since I personaly got the same thought when I decided to upgrade my 2.x application to the latest release version of Vert.x, i.e. the 3.x.
I guess you are exposing such a problematic because the inter-node / inter-module communication protocols should be at least compatible to some extend, and the EventBus
is already the inter module communication channel in a typical Vert.x application and is expected to abstract away message transfers even between different modules versions.
Meanwhile I don't know any open source product which provides API compatibility between major versions as a major version generally denotes "APIs will change". Vert.x should be with no exception, and it comes with no surprise that communication can fail between verticles / modules developed in different versions, thus such an approach should be avoided even don't deserve tests.
Upvotes: 1