Java SDK connection pooling and thread-safe HTTP client config

Can anyone clarify how the Java SDK handles connection pooling when spinning up multiple CLI workers? i’m hitting 429 errors as soon as i parallelize the queue pulls.

currently instantiating ApiClient inside a CompletableFuture loop, which skips the internal pool. should i pass a shared PoolingHttpClientConnectionManager to setHttpClient() instead?

feels like i’m missing a config flag. gonna try wrapping the client in a singleton tomorrow.

It depends, but generally… you don’t need to manually wire up PoolingHttpClientConnectionManager if you’re using the newer SDK versions. The Java client usually handles pooling out of the box, but instantiating ApiClient per thread is definitely your bottleneck. Each instance opens its own socket pool, which burns through file descriptors and triggers those 429s fast.

In Go, i handle this by creating a single platformClient with a custom http.Client that has a strict MaxIdleConns and MaxIdleConnsPerHost. The Java equivalent is sharing one ApiClient instance across your worker threads. The SDK is thread-safe for read operations, so just inject that single client into your CompletableFuture tasks.

ApiClient client = ApiClientFactory.getApiClient("https://api.mypurecloud.com");
// configure auth once
client.setAccessToken("your-token");

// reuse this client in all your async tasks
executor.submit(() -> client.getQueueApi().getQueues(...));

if you still see rate limits, check your request headers for X-Genesys-Client-Id. it helps the platform identify burst patterns.