本文整理了Java中io.vertx.ext.web.client.HttpRequest.timeout()
方法的一些代码示例,展示了HttpRequest.timeout()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.timeout()
方法的具体详情如下:
包路径:io.vertx.ext.web.client.HttpRequest
类名称:HttpRequest
方法名:timeout
暂无
代码示例来源:origin: io.vertx/vertx-rx-java
/**
* Configures the amount of time in milliseconds after which if the request does not return any data within the timeout
* period an {@link java.util.concurrent.TimeoutException} fails the request.
* <p>
* Setting zero or a negative <code>value</code> disables the timeout.
* @param value The quantity of time in milliseconds.
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.rxjava.ext.web.client.HttpRequest<T> timeout(long value) {
delegate.timeout(value);
return this;
}
代码示例来源:origin: vert-x3/vertx-rx
/**
* Configures the amount of time in milliseconds after which if the request does not return any data within the timeout
* period an {@link java.util.concurrent.TimeoutException} fails the request.
* <p>
* Setting zero or a negative <code>value</code> disables the timeout.
* @param value The quantity of time in milliseconds.
* @return a reference to this, so the API can be used fluently
*/
public io.vertx.rxjava.ext.web.client.HttpRequest<T> timeout(long value) {
delegate.timeout(value);
return this;
}
代码示例来源:origin: redhat-developer-demos/istio-tutorial
private void getNow(RoutingContext ctx) {
count++;
final WebClient client = WebClient.create(vertx);
client.get(80, HTTP_NOW, "/")
.timeout(5000)
.as(BodyCodec.jsonObject())
.send(ar -> {
if (ar.succeeded()) {
HttpResponse<JsonObject> response = ar.result();
JsonObject body = response.body();
String now = body.getJsonObject("now").getString("rfc2822");
ctx.response().end(now + " " + String.format(RESPONSE_STRING_FORMAT, HOSTNAME, count));
} else {
ctx.response().setStatusCode(503).end(ar.cause().getMessage());
}
});
}
代码示例来源:origin: io.vertx/vertx-consul-client
rq.timeout(timeoutMs);
代码示例来源:origin: EnMasseProject/enmasse
/**
* Get all info about messaging client (stdOut, stdErr, code, isRunning)
*
* @param uuid client id
* @return
* @throws InterruptedException
* @throws ExecutionException
* @throws TimeoutException
*/
public JsonObject getClientInfo(String uuid) throws InterruptedException, ExecutionException, TimeoutException {
CompletableFuture<JsonObject> responsePromise = new CompletableFuture<>();
JsonObject request = new JsonObject();
request.put("id", uuid);
client.get(endpoint.getPort(), endpoint.getHost(), "")
.as(BodyCodec.jsonObject())
.timeout(120000)
.sendJson(request,
ar -> responseHandler(ar, responsePromise, HttpURLConnection.HTTP_OK, "Error getting messaging clients info"));
return responsePromise.get(150000, TimeUnit.SECONDS);
}
代码示例来源:origin: EnMasseProject/enmasse
/**
* Stop messaging client and get all informations about them (stdOut, stdErr, code, isRunning)
*
* @param uuid client id
* @return
* @throws InterruptedException
* @throws ExecutionException
* @throws TimeoutException
*/
public JsonObject stopClient(String uuid) throws InterruptedException, ExecutionException, TimeoutException {
CompletableFuture<JsonObject> responsePromise = new CompletableFuture<>();
JsonObject request = new JsonObject();
request.put("id", uuid);
client.delete(endpoint.getPort(), endpoint.getHost(), "")
.as(BodyCodec.jsonObject())
.timeout(120000)
.sendJson(request,
ar -> responseHandler(ar, responsePromise, HttpURLConnection.HTTP_OK, "Error removing messaging clients"));
return responsePromise.get(150000, TimeUnit.SECONDS);
}
代码示例来源:origin: cescoffier/vertx-kubernetes-workshop
ar.result().get("/")
.as(BodyCodec.jsonArray())
.timeout(5000)
.send(res -> {
if (res.succeeded()) {
代码示例来源:origin: io.gravitee.elasticsearch/gravitee-common-elasticsearch
@Override
public void handle(HttpContext context) {
context.request()
.timeout(configuration.getRequestTimeout())
.putHeader(HttpHeaders.ACCEPT, CONTENT_TYPE)
.putHeader(HttpHeaders.ACCEPT_CHARSET, StandardCharsets.UTF_8.name());
// Basic authentication
if (authorizationHeader != null) {
context.request().putHeader(HttpHeaders.AUTHORIZATION, authorizationHeader);
}
context.next();
}
});
代码示例来源:origin: io.vertx/vertx-web-client
@Test
public void testTimeout() throws Exception {
AtomicInteger count = new AtomicInteger();
server.requestHandler(req -> count.incrementAndGet());
startServer();
HttpRequest<Buffer> get = client.get(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/somepath");
get.timeout(50).send(onFailure(err -> {
assertTrue(err instanceof TimeoutException);
testComplete();
}));
await();
}
代码示例来源:origin: EliMirren/VX-API-Gateway
if (service != null) {
for (VxApiServerURLInfo urlinfo : service) {
webClient.requestAbs(serOptions.getMethod(), urlinfo.getUrl()).timeout(serOptions.getTimeOut()).send(res -> {
if (res.succeeded()) {
int statusCode = res.result().statusCode();
代码示例来源:origin: silentbalanceyh/vertx-zero
request.timeout(30000);
代码示例来源:origin: cn.vertxup/vertx-up
request.timeout(30000);
代码示例来源:origin: EliMirren/VX-API-Gateway
loadParam(rct, requestPath, headers, queryParams, bodyParams);
HttpRequest<Buffer> request = webClient.requestAbs(serOptions.getMethod(), requestPath).timeout(serOptions.getTimeOut());
request.headers().addAll(headers);
request.queryParams().addAll(queryParams);
内容来源于网络,如有侵权,请联系作者删除!