spring事务一次完整流程,创建 》确认获取连接 》完成 》提交》释放链接
标签:25,06,07,22,Spring,流程,34,日志,main From: https://www.cnblogs.com/Nuwa/p/17455659.htmlDataSourceTransactionManager
//Step1. 进入业务方法前,依据事物切面创建事务对象
2019-07-06 22:34:24,819 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Creating new transaction with name [com.sample.service.CompanyServiceImpl.addCompany]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
//Step2. 获取数据库连接,这里是配置了从c3p0连接池中获取
2019-07-06 22:34:25,292 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Acquired Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@97e93f1 [wrapping: com.mysql.jdbc.JDBC4Connection@5a5a729f]] for JDBC transaction
2019-07-06 22:34:25,292 [C3P0PooledConnectionPoolManager[identityToken->1hge138a31jetm9i12oidyb|383bfa16]-HelperThread-#1] TRACE c.m.v.resourcepool.BasicResourcePool - trace com.mchange.v2.resourcepool.BasicResourcePool@491b9b8 [managed: 2, unused: 1, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@6e3a9bce)
2019-07-06 22:34:25,292 [C3P0PooledConnectionPoolManager[identityToken->1hge138a31jetm9i12oidyb|383bfa16]-HelperThread-#1] TRACE c.m.v.resourcepool.BasicResourcePool - decremented pending_acquires: 1
2019-07-06 22:34:25,292 [C3P0PooledConnectionPoolManager[identityToken->1hge138a31jetm9i12oidyb|383bfa16]-HelperThread-#1] TRACE c.m.v.resourcepool.BasicResourcePool - Acquisition series terminated successfully. Decremented pending_acquires [1], attempts_remaining: 30//这里是因为我们设置了手动提交事务,,之后就会之行具体业务方法
2019-07-06 22:34:25,294 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Switching JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@97e93f1 [wrapping: com.mysql.jdbc.JDBC4Connection@5a5a729f]] to manual commit//Step3. 完成事务,jdbc commit;之后触发各种监听事件,时序为 beforeCommit --> beforeCompletion --> afterCommit -->afterCompletion
2019-07-06 22:34:25,320 [main] TRACE o.s.t.i.TransactionInterceptor - Completing transaction for [com.sample.service.CompanyServiceImpl.addCompany]
2019-07-06 22:34:25,320 [main] TRACE o.s.j.d.DataSourceTransactionManager - Triggering beforeCommit synchronization
2019-07-06 22:34:25,320 [main] TRACE o.s.j.d.DataSourceTransactionManager - Triggering beforeCompletion synchronization
2019-07-06 22:34:25,320 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Initiating transaction commit
2019-07-06 22:34:25,320 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Committing JDBC transaction on Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@97e93f1 [wrapping: com.mysql.jdbc.JDBC4Connection@5a5a729f]]
2019-07-06 22:34:25,366 [main] TRACE o.s.j.d.DataSourceTransactionManager - Triggering afterCommit synchronization2019-07-06 22:34:25,366 [main] TRACE o.s.t.s.TransactionSynchronizationManager - Clearing transaction synchronization
2019-07-06 22:34:25,367 [main] TRACE o.s.j.d.DataSourceTransactionManager - Triggering afterCompletion synchronization//Step4. 释放连接,归还连接到连接池
2019-07-06 22:34:25,367 [main] TRACE o.s.t.s.TransactionSynchronizationManager - Removed value [org.springframework.jdbc.datasource.ConnectionHolder@5340477f] for key [com.mchange.v2.c3p0.ComboPooledDataSource[ identityToken -> 1hge138a31jetm9i12oidyb|383bfa16, dataSourceName -> 1hge138a31jetm9i12oidyb|383bfa16 ]] from thread [main]
2019-07-06 22:34:25,368 [main] DEBUG o.s.j.d.DataSourceTransactionManager - Releasing JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@97e93f1 [wrapping: com.mysql.jdbc.JDBC4Connection@5a5a729f]] after transaction