I want to create two separate JDBC data-sources (aka. connection pools) that would re use connections similar to following diagram.
.------.
'------'
| Data |
| base |
'------'
^
|
+------+-------+
| |
| Connection |
+--->| Pool Main |<----+
| | | |
| +--------------+ |
+------+----------+ +----------+--------+
|Connection Pool A| | Connection Pool B |
+-----------------+ +-------------------+
^ ^
| |
+-------+------+ +--------+-----+
| App Module A | | App Module B |
+--------------+ +--------------+
Idea is to have parent connection pool to have 10 connections limit, and each child source to have limit of 8.
So even if App module A uses all 8 connections, module B won't starve and would have at least two connection.
So to reword the question: I want to represent single connection pool in such way, that one part of application can have at least N connections of total M available. Reserving this N connections for each part of application.
Is this possible with any existing library, for example HikariCP?
P.S. This is spring boot application, but this should not matter as JDBC datasources can exist outside of spring. But perhaps Spring has some tricks for this use-case.