Search code examples
quarkusquarkus-rest-client

How to Set Connection Pool Size for a Quarkus REST Client Programmatically?


I'm working on a Quarkus project where I need to create a REST client programmatically using QuarkusRestClientBuilder. While using the annotated client (@RegisterRestClient), I know that the connection pool size can be configured via properties like quarkus.rest-client.connection-pool-size. However, I haven't found a way to set this property for my Rest Clients when building them programmatically.

Here's a simplified version of my current code:

SomeRestClient client =
    QuarkusRestClientBuilder.newBuilder()
        .baseUri(new URI(baseUrl))
        .proxyAddress("some-proxy-address", 80)
        .build(SomeRestClient.class);

Solution

  • You need to do something this:

    Client client = QuarkusRestClientBuilder.newBuilder().baseUri(uri)
                    .property(QuarkusRestClientProperties.CONNECTION_POOL_SIZE, 20)
                    .build(Client.class);