cancel
Showing results for 
Search instead for 
Did you mean: 

Connection Pool Setting using HTTPClientAccessor in SAP CAP Java Application

DC
Explorer
0 Kudos

Hi Team,

We are using this to send requests to a third party endpoint defined in Destinations in BTP

HttpDestination destination = DestinationAccessor.getDestination("my-destination").asHttp();<br>HttpClient client = HttpClientAccessor.getHttpClient(destination);<br>HttpResponse httpResponse = client.execute(httpPost);

Just wondering what the default values are for timeouts, connection pool etc. are???? We just need to make sure we have decent numbers for our production systems.

Planning to use DefaultHttpClientFactory if the defaults are not same :

- connection and connection request timeout - 5 s

- socket timeout - 30 s

- max connections - 200

- max connections per route - 20

HttpClientFactory factory = new DefaultHttpClientFactory();<br>HttpClient client = factory.createHttpClient(destination);

Appreciate any inputs on this.

marcbecker : any wisdom you can share here please?

🙂

Thanks

Dharmesh

View Entire Topic
jschneider
Advisor
Advisor
0 Kudos

Hi Dharmesh,

the API you are referring to belongs to the SAP Cloud SDK for Java.
As such, you can find guidance about the HTTP Client and related classes in our official documentation.

To also answer your question: By default, the `DefaultHttpClientFactory` uses the following configuration:

- Connection, Connection Request, and Socket timeout: 2 minutes
- Max total connections: 200
- Max connections per route: 100

You can easily customize these values to your needs by following the procedure in the linked documentation.
Please also note that the `HttpClientAccessor` already uses the `DefaultHttpClientFactory` (without any explicit arguments passed) under the hood; so both code snippets in your initial question will yield the same result in terms of configuration.

Hope that explanation helps

Best regards,
Johannes

DC
Explorer
0 Kudos

Hi Johannes

I understand the default for the DefaultHttpClientFactory.

Was wanting to confirm the defaults if we use

HttpClient client = HttpClientAccessor.getHttpClient(destination) ??????

client.execute();

Cheers

D

jschneider
Advisor
Advisor
0 Kudos

Okay then I guess your question has been answered, right?
(By default, the mentioned configuration is used)

By the way, you can also overwrite the `HttpClientFactory` that should be used in the `HttpClientAccessor` - once again, refer to the linked documentation for more details.

DC
Explorer
0 Kudos

Hi Johannes

Sorry, didn't read your last paragraph in your initial response.

Appreciate your prompt response.

Thanks