You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Notification for db connection acquired when LazyConnectionDataSourceProxy is used [SPR-17278] #21811
in: dataIssues in data modules (jdbc, orm, oxm, tx)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement
We are using LazyConnectionDataSourceProxy to lazily fetch DB connection. When DB connection is fetched from pool there is no notification fired which can tell that db connection has been acquired. This is really helpful whenever some action needs to be taken on acquiring db connection(eg. logging).
LazyConnectionDataSourceProxy will trigger a getConnection call on the configured targetDataSource whenever it acquires a new Connection. You could decorate that target DataSource accordingly, logging getConnection calls at that level.
Is there anything more specific you'd like to be notified of here?
Juergen Hoeller then it will will data source dependent. We use Hikari as data source, if we use different data source then things will have to be changed over there also. Instead if this change is done in LazyConnectionDataSourceProxy then it can be utilised irrespective of data sources.
What I meant is another DataSource decorator inbetween: E.g. a custom subclass of Spring's DelegatingDataSource, overriding the getConnection methods accordingly for some logging there before delegating to super. This could sit inbetween LazyConnectionDataSourceProxy and the actual connection pool, as one further layer of decoration (similar to InputStream decoration).
Alternatively, we could also bake some protected callback method into LazyConnectionDataSourceProxy itself, e.g. onConnectionRetrieval. At the moment we perform a callback already but just to checkDefaultConnectionProperties; you could override that one for that purpose but that's a bit of a workaround for a better named solution.
in: dataIssues in data modules (jdbc, orm, oxm, tx)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement
Activity
spring-projects-issues commentedon Sep 17, 2018
Juergen Hoeller commented
LazyConnectionDataSourceProxywill trigger agetConnectioncall on the configuredtargetDataSourcewhenever it acquires a newConnection. You could decorate that targetDataSourceaccordingly, logginggetConnectioncalls at that level.Is there anything more specific you'd like to be notified of here?
spring-projects-issues commentedon Sep 18, 2018
Keshav Gupta commented
Juergen Hoeller then it will will data source dependent. We use Hikari as data source, if we use different data source then things will have to be changed over there also. Instead if this change is done in LazyConnectionDataSourceProxy then it can be utilised irrespective of data sources.
spring-projects-issues commentedon Sep 18, 2018
Juergen Hoeller commented
What I meant is another
DataSourcedecorator inbetween: E.g. a custom subclass of Spring'sDelegatingDataSource, overriding thegetConnectionmethods accordingly for some logging there before delegating tosuper. This could sit inbetweenLazyConnectionDataSourceProxyand the actual connection pool, as one further layer of decoration (similar toInputStreamdecoration).Alternatively, we could also bake some protected callback method into
LazyConnectionDataSourceProxyitself, e.g.onConnectionRetrieval. At the moment we perform a callback already but just tocheckDefaultConnectionProperties; you could override that one for that purpose but that's a bit of a workaround for a better named solution.jhoeller commentedon Jul 13, 2023
With the options above in mind, I'm going to close this issue here.