io.vertx.ext.unit.Async.isCompleted()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中io.vertx.ext.unit.Async.isCompleted()方法的一些代码示例,展示了Async.isCompleted()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Async.isCompleted()方法的具体详情如下:
包路径:io.vertx.ext.unit.Async
类名称:Async
方法名:isCompleted

Async.isCompleted介绍

暂无

代码示例

代码示例来源:origin: io.vertx/vertx-kafka-client

ctx.assertTrue(handler.isCompleted() && assigned.isCompleted());
 finished.countDown();
});
 ctx.assertTrue(handler.isCompleted() && assigned.isCompleted());
 finished.countDown();
});

代码示例来源:origin: io.vertx/vertx-kafka-client

ctx.assertTrue(handler.isCompleted() && assigned.isCompleted());
 finished.countDown();
});
 ctx.assertTrue(handler.isCompleted() && assigned.isCompleted());
 finished.countDown();
});

代码示例来源:origin: vert-x3/vertx-kafka-client

ctx.assertTrue(handler.isCompleted() && assigned.isCompleted());
 finished.countDown();
});
 ctx.assertTrue(handler.isCompleted() && assigned.isCompleted());
 finished.countDown();
});

代码示例来源:origin: vert-x3/vertx-kafka-client

ctx.assertTrue(handler.isCompleted() && assigned.isCompleted());
 finished.countDown();
});
 ctx.assertTrue(handler.isCompleted() && assigned.isCompleted());
 finished.countDown();
});

代码示例来源:origin: io.vertx/vertx-mqtt

@Test
public void noConnectSent(TestContext context) {
 NetClient client = this.vertx.createNetClient();
 Async async = context.async();
 client.connect(MQTT_SERVER_PORT, MQTT_SERVER_HOST, done -> {
  if (done.succeeded()) {
   done.result().closeHandler(v -> {
    log.info("No CONNECT sent in " + MQTT_TIMEOUT_ON_CONNECT + " secs. Closing connection.");
    async.complete();
   });
  } else {
   context.fail();
  }
 });
 // check that the async is completed (so connection was closed by server) in
 // the specified timeout (+500 ms just for being sure)
 async.await(500 + MQTT_TIMEOUT_ON_CONNECT * 1000);
 if (!async.isCompleted())
  context.fail();
}

代码示例来源:origin: vert-x3/vertx-mqtt

@Test
public void noConnectSent(TestContext context) {
 NetClient client = this.vertx.createNetClient();
 Async async = context.async();
 client.connect(MQTT_SERVER_PORT, MQTT_SERVER_HOST, done -> {
  if (done.succeeded()) {
   done.result().closeHandler(v -> {
    log.info("No CONNECT sent in " + MQTT_TIMEOUT_ON_CONNECT + " secs. Closing connection.");
    async.complete();
   });
  } else {
   context.fail();
  }
 });
 // check that the async is completed (so connection was closed by server) in
 // the specified timeout (+500 ms just for being sure)
 async.await(500 + MQTT_TIMEOUT_ON_CONNECT * 1000);
 if (!async.isCompleted())
  context.fail();
}

代码示例来源:origin: vietj/vertx-http-proxy

@Test
public void testClientClosesDuringUpload(TestContext ctx) {
 Async async = ctx.async();
 Async closeLatch = ctx.async();
 SocketAddress backend = startHttpBackend(ctx, 8081, req -> {
  req.response().closeHandler(v -> {
   async.complete();
  });
  req.handler(buff -> {
   if (!closeLatch.isCompleted()) {
    closeLatch.complete();
   }
  });
 });
 startProxy(backend);
 HttpClient client = vertx.createHttpClient();
 HttpClientRequest req = client.post(8080, "localhost", "/", resp -> ctx.fail());
 req.putHeader("Content-Length", "2048");
 req.write(Buffer.buffer(new byte[1024]));
 closeLatch.awaitSuccess(10000);
 req.connection().close();
}

代码示例来源:origin: io.vertx/vertx-rabbitmq-client

@Test
public void consumerPrefetch(TestContext ctx) throws Exception {
 // 1. Limit number of unack messages to 2
 // 2. Send 3 messages
 // 3. Ensure only 2 messages received
 int count = 3;
 int amountOfUnAckMessages = count - 1;
 Async prefetchDone = ctx.async();
 client.basicQos(amountOfUnAckMessages, ctx.asyncAssertSuccess(v -> prefetchDone.complete()));
 prefetchDone.await();
 Set<String> messages = createMessages(count);
 String queue = setupQueue(ctx, messages);
 String address = queue + ".address";
 Async receivedExpectedNumberOfMessages = ctx.async(amountOfUnAckMessages);
 vertx.eventBus().consumer(address, msg -> {
  ctx.assertFalse(receivedExpectedNumberOfMessages.isCompleted());
  receivedExpectedNumberOfMessages.countDown();
 });
 client.basicConsume(queue, address, false, ctx.asyncAssertSuccess());
 receivedExpectedNumberOfMessages.awaitSuccess(15000);
 // At the point we are sure, that we have already received 2 messages.
 // But, if 3rd message will arrive the test will fail in the next second.
 Async async = ctx.async();
 vertx.setTimer(1000, spent -> async.countDown());
}

代码示例来源:origin: vert-x3/vertx-rabbitmq-client

@Test
public void consumerPrefetch(TestContext ctx) throws Exception {
 // 1. Limit number of unack messages to 2
 // 2. Send 3 messages
 // 3. Ensure only 2 messages received
 int count = 3;
 int amountOfUnAckMessages = count - 1;
 Async prefetchDone = ctx.async();
 client.basicQos(amountOfUnAckMessages, ctx.asyncAssertSuccess(v -> prefetchDone.complete()));
 prefetchDone.await();
 Set<String> messages = createMessages(count);
 String queue = setupQueue(ctx, messages);
 String address = queue + ".address";
 Async receivedExpectedNumberOfMessages = ctx.async(amountOfUnAckMessages);
 vertx.eventBus().consumer(address, msg -> {
  ctx.assertFalse(receivedExpectedNumberOfMessages.isCompleted());
  receivedExpectedNumberOfMessages.countDown();
 });
 client.basicConsume(queue, address, false, ctx.asyncAssertSuccess());
 receivedExpectedNumberOfMessages.awaitSuccess(15000);
 // At the point we are sure, that we have already received 2 messages.
 // But, if 3rd message will arrive the test will fail in the next second.
 Async async = ctx.async();
 vertx.setTimer(1000, spent -> async.countDown());
}

相关文章