List of usage examples for io.vertx.core Vertx close
void close(Handler<AsyncResult<Void>> completionHandler);
From source file:org.apache.servicecomb.foundation.vertx.VertxUtils.java
License:Apache License
public static CompletableFuture<Void> closeVertxByName(String name) { LOGGER.info("Closing vertx {}.", name); CompletableFuture<Void> future = new CompletableFuture<>(); Vertx vertx = vertxMap.remove(name); if (vertx == null) { LOGGER.info("Vertx {} not exist.", name); future.complete(null);/* w w w. java 2 s .c o m*/ return future; } vertx.close(ar -> { if (ar.succeeded()) { LOGGER.info("Success to close vertx {}.", name); future.complete(null); return; } future.completeExceptionally(ar.cause()); }); return future; }
From source file:org.eclipse.hono.tests.registry.DeviceRegistryAmqpTestSupport.java
License:Open Source License
/** * Closes the connection of the provided client to the device registry service. * <p>//from w w w .j a va2s.c o m * Any senders or consumers opened by this client will be implicitly closed as well. Any subsequent attempts to * connect this client again will fail. * * @param vertx The Vert.x instance on which the client is executed on. * @param ctx The test context that the tests are executed on. * @param client The client to shutdown. * @throws NullPointerException if any of the parameters is {@code null}. */ protected static void shutdownDeviceRegistryClient(final TestContext ctx, final Vertx vertx, final HonoClient client) { final Future<Void> clientTracker = Future.future(); if (client != null) { client.shutdown(clientTracker.completer()); } else { clientTracker.complete(); } clientTracker.otherwiseEmpty().compose(s -> { final Future<Void> vertxTracker = Future.future(); vertx.close(vertxTracker.completer()); return vertxTracker; }).setHandler(ctx.asyncAssertSuccess()); }