vert.xvertx-verticlevertx-httpclient

Vertx Webclient pool


I am using vertx WebClient to consume 3 different(host) APIs, below is how I use Webclient,

WebClientOptions options = new WebClientOptions();
    options.setSsl(true);
    options.setMaxPoolSize(50);
    client = WebClient.create(vertx, options);
client.postAbs(url)
      .timeout(10000)
      .sendJsonObject(payLoad)

How would the connection be pooled? I checked the WebClient code(WebClientBase>HttpRequestImpl>HttpContext>HttpClientRequest) but I was not able to find where and how connection pooling is implemented.

Is it good to create multiple WebClient based on the API host or one client for all the APIs? Please share your inputs.


Solution

  • The max pool size is per destination.

    It is fine to use a single WebClient for different destinations. You would create a client per destination if you needed to tune the options differently for each of them.

    The pool implementation lies in the underlying HttpClient.