I am using the standard HikariCP implementation with the latest SpringBoot application. The scenario is like this. A call is made to my API that takes something from DB and after that calls another microservice. By default, the HikariCP has a pool of 10. The call to the internal microservice can take up to 20 minutes to respond. Scenario:
External Client -> MyApi -> SomeMicroService <- reponse time 20 minutes.
If I have 11 requests in parallel I have a problem because I receive:
HikariPool-1 - Connection is not available, request timed out after 30000ms
Why? Because the connection is returned to the pool after the session is closed.
Is there a way to close the connection after the DB call is made? If in one session we have 10 JPA requests is using the same connection but if you have 30 calls in parallel 10 will be ok and 20 will end up with the error.
I know that I can increase the pool from 10 to 100 but is there any other solution. @Transaction is not working. The connection is remaining open until the request is resolved one way on another.
So my question is: How to release the connection after DB request/response is made and create another one when it needs.
I'm using SpringBoot, SprinJPA, hibernate with default configurations.
Thanks in advance.