use of io.vertx.core.spi.cluster.RegistrationUpdateEvent in project vert.x by eclipse.
the class ClusteredEventBusTest method testSendWriteHandler.
@Test
public void testSendWriteHandler() throws Exception {
CountDownLatch updateLatch = new CountDownLatch(3);
Supplier<VertxOptions> options = () -> getOptions().setClusterManager(new WrappedClusterManager(getClusterManager()) {
@Override
public void init(Vertx vertx, NodeSelector nodeSelector) {
super.init(vertx, new WrappedNodeSelector(nodeSelector) {
@Override
public void registrationsUpdated(RegistrationUpdateEvent event) {
super.registrationsUpdated(event);
if (event.address().equals(ADDRESS1) && event.registrations().size() == 1) {
updateLatch.countDown();
}
}
@Override
public boolean wantsUpdatesFor(String address) {
return true;
}
});
}
});
startNodes(options.get(), options.get());
waitFor(2);
vertices[1].eventBus().consumer(ADDRESS1, msg -> complete()).completionHandler(onSuccess(v1 -> updateLatch.countDown()));
awaitLatch(updateLatch);
MessageProducer<String> producer = vertices[0].eventBus().sender(ADDRESS1);
producer.write("body", onSuccess(v2 -> complete()));
await();
}
Aggregations