]
Luis Barreiro commented on AG-136:
----------------------------------
Initially only acquire and return events will be available in this new interface. It was
discussed that create and destroy were added as well, but the conclusion was that there is
not enough interest in those events. They may be added in the future.
Add a safe callback interface for pool events
---------------------------------------------
Key: AG-136
URL:
https://issues.redhat.com/browse/AG-136
Project: Agroal
Issue Type: Feature Request
Components: api, pool
Affects Versions: 1.7
Reporter: Luis Barreiro
Assignee: Luis Barreiro
Priority: Major
Fix For: 1.8
There is a need for a callback to intercept pool events that is safe for applications to
use.
Right now the current listener interface is fine for container implementations, but
should not be used by higher level applications because:
* The {{AgroalDataSourceListener}} interface was not designed with the Interceptor
concept in mind. Agroal always invoke the listeners in the given order, so if there are 2
listeners with common concerns,only one of them will be effective.
* The Listener gives access to the raw {{java.sql.Connection}} and therefore any error
may cause chaos on the pool (leave an invalid connection on the pool, etc.)
* Some methods on the listener are invoked by Agroal's own thread and therefore
should not execute any long running task (that is not a problem in the context of this
issue, but may be if we expose this interface as API)
* When running Agroal with a TransactionManager, the life-cycle of the connections can be
slightly different as this is associated with the transaction. This does not map well on
the current listener interface.
A new interface PoolInteceptor should be added to address this issues.