首页 > 其他分享 >从日志记一次Spring事务完整流程

从日志记一次Spring事务完整流程

时间:2023-06-04 14:44:10浏览次数:43  
标签:25 06 07 22 Spring 流程 34 日志 main

spring事务一次完整流程,创建 》确认获取连接 》完成 》提交》释放链接

DataSourceTransactionManager

//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 synchronization

2019-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

标签:25,06,07,22,Spring,流程,34,日志,main
From: https://www.cnblogs.com/Nuwa/p/17455659.html

相关文章

  • Spring 3.0.5+MyBatis3.0.4整合非完全例子
    基于注解的mybatis和spring整合:[url]http://huangmin001.iteye.com/blog/1185806[/url][color=red]这个文章说的很详细,很值得一看[/color].Maven+SpringMVC+Mybatis【绝非原创,单纯整理】【四】:[url]http://playgod1984.iteye.com/blog/984113[/ur......
  • 搭建Hibernate日志-log4jdbc
    官方:[url]https://code.google.com/p/log4jdbc/[/url]log4jdbc分析sql性能[url]http://hongliangpan.iteye.com/blog/1088398[/url]xml配置方法:log4jdbc日志框架介绍[url]http://blog.sina.com.cn/s/blog_57769b7b0101m1il.html[/url][url]http://xia......
  • spring jdbcTemplate使用
    参考:springjdbcTemplate使用[url]http://log-cd.iteye.com/blog/215059[/url]SpringJdbcTemplate与事务管理学习[url]http://www.iteye.com/topic/480432[/url]SimpleJdbcTemplate在spring3.1已经过时了,我就改为使用jdbcTemplate和namedParameterJdbcOperations写sql查询......
  • SpringSecurity使用JWT
    SpringSecurity的UsernamePasswordAuthenticationFilter用于处理认证。要整合JWT,只需在认证成功后生成TOKEN并通过响应头写回客户端。在新增一个过滤器用于校验TOKEN。新建SpringBoot项目,添加依赖:<dependency><groupId>org.springframework.boot</groupId>......
  • Spring常用注解
    SVN多版本库环境的搭建OAuth2.0是什么?看这篇文章就够了。前端JavaPython等资源合集大放送使用注解之前要开启自动扫描功能,其中base-package为需要扫描的包(含子包)。<context:component-scanbase-package="cn.com.cms"/>@Configuration把一个类作为一个IoC容器,它的某个方法头上......
  • Spring返回json格式数据的三种方式
    SVN多版本库环境的搭建OAuth2.0是什么?看这篇文章就够了。前端JavaPython等资源合集大放送目前前后端分离大行其道,如何进行前后分类是各个项目需要考虑的问题。如何使用Spring进行前后端分离呢?返回json格式数据是前后端分离的最佳选择。下面介绍使用Spring进行前后端分离的常用三......
  • 【整套视频】spring / springmvc+mybatis
    Spring常用注解redis视频集合,看完这些别说不会redisday88-js对象.rarday87-项目部署和面试指导10.rarday86-订单流程09.rarday85-购物车和订单提交08.rarday84-单品页查询静态化07.rarday83-用户登录和个人中心06.rarday82-商品审核上架和首页筛选05.rarday81-商品添加04.rarday80-......
  • 【视频】SpringBoot为啥到了不学不行的阶段
    Spring常用注解redis视频集合,看完这些别说不会redis01-SpringBoot视频教程_SpringBoot简介.rar02-SpringBoot视频教程_SpringBoot主要特性.rar03-SpringBoot视频教程_SpringBoot四大核心功能.rar04-SpringBoot视频教程_SpringBoot基础开发环境.rar05-SpringBoot视频教程_SpringBoot......
  • dubbo源码学习(二) : spring 自定义标签
    做dubbo的配置时很容易发现,dubbo有一套自己的标签,提供给开发者配置,其实每一个标签对应着一个实体,在容器启动的时候,dubbo会对所有的配置进行解析然后将解析后的内容设置到实体里,最终dubbo会根据实体中的值生成贯穿全局的统一URL。利用自定义标签使配置简单明......
  • springcloud入门
    1、启动注册中心springcloud-eureka-serverspring.cloud.EurekaServerApplication2、访问注册中心http://127.0.0.1:8100/root/eureka3、启动配置中心springcloud-config-serverspring.cloud.ConfigServerApplication启动完毕后可以在注册中心看到配置中心已经注册4......