Hi folks,
I am observing poor performance with vertx-web-client 4.5.7. I am only seeing 0-3 requests served per second. I'm sure I am doing something wrong.
Here is my abbreviated code:
```
vertx = Vertx.vertx();
router = Router.router(vertx);
webClient = WebClient.create(vertx);
router.route().handler(CorsHandler.create("*")
.allowedMethod(HttpMethod.GET)
.allowedMethod(HttpMethod.POST)
.allowedMethod(HttpMethod.PUT)
.allowedMethod(HttpMethod.OPTIONS)
.allowedMethod(HttpMethod.DELETE)
.allowedHeader("Content-Type")
);
router.route("/api/*").handler(ResponseTimeHandler.create());
router.route("/api/*").handler(LoggerHandler.create());
router.route("/api/*").handler(TimeoutHandler.create(TimeUnit.SECONDS.toMillis(TIMEOUT_SECONDS)));
router.get("/api/v1/my_endpoint").handler(rc -> {
var request = webClient.getAbs("another-endpoint");
request
.send()
.flatMap(ar -> {
if (ar.statusCode() != 200) {
return Future.failedFuture(ar.bodyAsString());
} else {
final List<Map<String, Object>> values = GSON.fromJson(ar.bodyAsString(), new TypeToken<List<Map<String, Object>>>() {}.getType());
return webClient.postAbs("another-other-endpoint")
.sendBuffer(Buffer.buffer(GSON.toJson(values)));
}
})
.onComplete(ar -> {
if (ar.succeeded()) {
rc.response().setStatusCode(200).putHeader(CONTENT_TYPE_HEADER, CONTENT_TYPE_APPLICATION_JSON).end("OK");
} else {
rc.response().setStatusCode(500).putHeader(CONTENT_TYPE_HEADER, CONTENT_TYPE_APPLICATION_JSON).end(ar.cause().getMessage());
}
});
})
final HttpServer httpServer = vertx.createHttpServer(new HttpServerOptions().setMaxHeaderSize(62768))
.requestHandler(router);
logger.info("WEB,STARTING_SERVER,PORT,{}", webserverPort);
httpServer.listen(webserverPort, result -> {
if (result.failed()) {
final String error = String.format("UNABLE_TO_BIND_ON_PORT,%s,%s", webserverPort,
result.cause());
logger.error(error);
// potentially send critical error event
// and handle all critical errors in one place
System.exit(-1);
}
logger.info("WEB,SERVER_STARTED,PORT,{}", webserverPort);
});
```
As you can see my code is pretty straight-forward -- very little configuration and basic usage of send() and flatMap().
Can someone please advise? Thanks in advance.