Consolidation of RestEasy Client Connections

We have a @ApplicationScoped bean where we want to use the RestEasy nested client, and I'm trying to figure out how the actual connection occurs when the connection pool comes into play and therefore which of the objects in the chain for injection. I mean, it makes no sense to enter ResteasyClientBuilder if calling .build on it creates a new connection pool each time.

This is how I create the constructor:

ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder().asyncExecutor(es).connectionPoolSize(50);

I know that internally this uses the PoolingClientConnectionManager, which is thread safe, so it will be compatible with ApplicationScoped.

Here are further calls, including a GET call (doSomething)

ResteasyClient client = clientBuilder.build();
IAction actionService = client.target(URI.create("http://" + actionHost + "/action")).proxy(IAction.class);
XXXResponse response = actionService.doSomething(a, b);

Where the actual connection occurs, from where it is pushed out of the pool and returned back to the pool. That is, can I add an actionService above and multithreaded doSomething calls (or other methods in the "service") to get a new connection from the pool each time?

+4
source share

All Articles