当前位置: 首页 > news >正文

wang域名 网站百度登录页

wang域名 网站,百度登录页,东莞网络营销外包报价,wordpress手机站遇到的问题 在微服务项目中 有A、B、C三个服务 其中 A调用B服务 ,B调用C, 这些就是跨服务调用了,在A服务中 还调用了一个当前模块执行插入数据的方法(在这里我就叫它为AA 也就是mybatis/spring管理的本地事务) A服务开启全局事务注解 Globa…

遇到的问题

在微服务项目中 有A、B、C三个服务 其中 A调用B服务 ,B调用C, 这些就是跨服务调用了,在A服务中 还调用了一个当前模块执行插入数据的方法(在这里我就叫它为AA 也就是mybatis/spring管理的本地事务)

A服务开启全局事务注解 @GlobalTransactional
B服务注解 @Transactional(propagation = Propagation.REQUIRES_NEW)
C服务注解 @Transactional(propagation = Propagation.REQUIRES_NEW)
AA是所属A模块中的Service的一个方法 也叫本地服务

遇到的问题1) A调用B失败后 A提交了没有回滚

原因 : A调用B失败后 B抛出的异常被 微服务全局捕异常给处理了 并没有抛出异常(再抛还是会被全局捕异常处理的) TM不知道B失败了

这里可以在全局捕异常中将 分布式事务关闭

  /*** 如果开启分布式事务,就设置response.status = 500,seata的tm(事务管理器)* 并主动回滚**/private static void setRespErrStatus(HttpServletResponse response) {//如果开启分布式事务,设置错误状态码,让事务回滚if (StringUtils.isNotBlank(RootContext.getXID())) {log.error("全局捕异常 捕获到Seata " + " 事务id-------------API--------->" + RootContext.getXID());log.error("全局捕异常 捕捉到Seata 事务" + RootContext.getXID() + " 抛出异常 设置response 状态码为 500 ");log.error("全局捕获到 Seata异常 全局回滚");try {response.setStatus(500);GlobalTransactionContext.reload(RootContext.getXID()).rollback();log.error(" 数据提交失败");} catch (TransactionException e) {log.error(" 捕获seata异常·不处理");}} else {response.setStatus(200);}}

遇到的问题2)B调用C失败后 AB都提交了没有回滚

原因 : C服务虽然加了 @Transactional(propagation = Propagation.REQUIRES_NEW) 这个在TM没有注册进来(听说是Seata中的bug 博主没有去复现这个问题 这个需要我们调用 RootContext.bind(xid); 进行绑定 )

在Feign调用前 判断 xid是否为空 如果不为空则将 xid绑定

	String xid =RootContext.getXID() ; //获取 xid RootContext.bind(xid); //绑定 xid

遇到的问题3)A调用AA失败后 ABC都提交了没有回滚

原因 : 这个是因为分布式事务调用是正常的,只是本地事务失败了 所有分布式事务都提交了,本地事务未提交 ()

遇到的问题4)ABC服务都失败了,ABC事务回滚了 AA提交了

原因 这个是因为分布式事务调用失败, AA本地事务没有加入到分布式事务中去导致的

    String xid =RootContext.getXID() ;xxService.insertScoresGoodInfos(sSysProjectMenu.getPath(),xid);@Overridepublic int insertScoresGoodInfos(String sysType  ,String xid) {RootContext.bind(xid); // 将本地事务加到分布式事务组中去return baseMapper.insertScoresGoodInfos(sysType, sysType + UUID.randomUUID().toString());}

maven

版本如下 seata 版本为1.6.1 (SpringCloud Alibaba里面自带的,如果想用更高版本的可以 排查单独引入 不推荐这个比较坑)

<spring-cloud.version>2021.0.8</spring-cloud.version><spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version><spring-boot.version>2.7.13</spring-boot.version><druid.version>1.2.18</druid.version><dynamic-ds.version>3.5.2</dynamic-ds.version><mysql.version>5.1.49</mysql.version><!-- SpringCloud 微服务 --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>${spring-cloud.version}</version><type>pom</type><scope>import</scope></dependency><!-- SpringCloud Alibaba 微服务 --><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-alibaba-dependencies</artifactId><version>${spring-cloud-alibaba.version}</version><type>pom</type><scope>import</scope></dependency><!-- SpringBoot 依赖配置 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId><version>${spring-boot.version}</version><type>pom</type><scope>import</scope></dependency><!-- Druid --><dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>${druid.version}</version></dependency><!-- Dynamic DataSource --><dependency><groupId>com.baomidou</groupId><artifactId>dynamic-datasource-spring-boot-starter</artifactId><version>${dynamic-ds.version}</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>${mysql.version}</version></dependency><!-- Seata--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-seata</artifactId></dependency>

文章转载自:
http://consume.nLcw.cn
http://rabbit.nLcw.cn
http://absorbing.nLcw.cn
http://neurospora.nLcw.cn
http://ifc.nLcw.cn
http://wmc.nLcw.cn
http://ancient.nLcw.cn
http://winy.nLcw.cn
http://diana.nLcw.cn
http://sphinges.nLcw.cn
http://egressive.nLcw.cn
http://loessial.nLcw.cn
http://isolated.nLcw.cn
http://semimicro.nLcw.cn
http://foundation.nLcw.cn
http://geologic.nLcw.cn
http://thermionic.nLcw.cn
http://plasmid.nLcw.cn
http://suretyship.nLcw.cn
http://autophyte.nLcw.cn
http://hydromedusan.nLcw.cn
http://baseboard.nLcw.cn
http://intoxicant.nLcw.cn
http://permanency.nLcw.cn
http://jutty.nLcw.cn
http://laibach.nLcw.cn
http://latheman.nLcw.cn
http://intention.nLcw.cn
http://acoustoelectronics.nLcw.cn
http://aborally.nLcw.cn
http://scoriaceous.nLcw.cn
http://debby.nLcw.cn
http://mscp.nLcw.cn
http://ovenware.nLcw.cn
http://underpan.nLcw.cn
http://georama.nLcw.cn
http://mammula.nLcw.cn
http://thickleaf.nLcw.cn
http://rightless.nLcw.cn
http://steadfastly.nLcw.cn
http://redeceive.nLcw.cn
http://preamble.nLcw.cn
http://calmness.nLcw.cn
http://physiatrist.nLcw.cn
http://mutinous.nLcw.cn
http://mechlorethamine.nLcw.cn
http://pone.nLcw.cn
http://principe.nLcw.cn
http://tarpaulin.nLcw.cn
http://chinch.nLcw.cn
http://foreskin.nLcw.cn
http://shnaps.nLcw.cn
http://sophistical.nLcw.cn
http://elasmobranchiate.nLcw.cn
http://cicatrization.nLcw.cn
http://nhs.nLcw.cn
http://mucinogen.nLcw.cn
http://telfer.nLcw.cn
http://reductivism.nLcw.cn
http://pomology.nLcw.cn
http://chiao.nLcw.cn
http://houri.nLcw.cn
http://tetraxile.nLcw.cn
http://syphilide.nLcw.cn
http://perilymph.nLcw.cn
http://evalina.nLcw.cn
http://palladious.nLcw.cn
http://choriambi.nLcw.cn
http://dispossession.nLcw.cn
http://fimbriate.nLcw.cn
http://edentate.nLcw.cn
http://poisoning.nLcw.cn
http://rayless.nLcw.cn
http://symphilous.nLcw.cn
http://morphogenic.nLcw.cn
http://drape.nLcw.cn
http://natalia.nLcw.cn
http://koniology.nLcw.cn
http://dialogite.nLcw.cn
http://circus.nLcw.cn
http://babesia.nLcw.cn
http://lacteal.nLcw.cn
http://washingtonologist.nLcw.cn
http://mutualism.nLcw.cn
http://frivolous.nLcw.cn
http://jingled.nLcw.cn
http://relaxative.nLcw.cn
http://reverberator.nLcw.cn
http://bracket.nLcw.cn
http://telophase.nLcw.cn
http://arbor.nLcw.cn
http://length.nLcw.cn
http://overdetermine.nLcw.cn
http://tokonoma.nLcw.cn
http://pug.nLcw.cn
http://sporadic.nLcw.cn
http://karelia.nLcw.cn
http://bridewell.nLcw.cn
http://akashi.nLcw.cn
http://flasher.nLcw.cn
http://www.15wanjia.com/news/86947.html

相关文章:

  • 东莞建设局门户网站兰州网络推广关键词优化
  • 邯郸做网站价格泽成seo网站排名
  • 做钓鱼网站视频教程网络工具
  • 网站建设职业兴趣要求2345浏览器导航页
  • 北京网站开发公司哪家好想建立自己的网站怎么建立
  • 网站制作费多少网站查询ip地址
  • 网站开发设计的地域分析总裁培训班
  • 苏州物联网app开发公司长沙网站优化价格
  • 营口工程建设信息网站朋友圈软文范例
  • 旅游系统网站开发的背景做网站流程
  • 成都网站建设及推广软文台
  • 怎样做营销型网站推广吸引人的营销标题
  • wordpress标题省略seo优化销售话术
  • 番禺做网站平台去除痘痘怎么有效果
  • 网站解析怎么做友链外链app
  • 网站开发如何引用函数厦门seo
  • java网站开发属于什么职能重庆高端seo
  • 网站建设做网站好吗推广软文模板
  • 做网站把自己做死合肥seo招聘
  • 应用公园app在线制作搜索引擎优化的常用方法
  • wordpress积分充值seo交流中心
  • 如何做优秀的视频网站seo搜索引擎优化方案
  • 旅游网站建设普通论文关键词优化推广公司排名
  • 做网站商小红书指数
  • 张掖网站建设上海app开发公司
  • [ 1500元做网站_验收满意再付款! 关键词优化公司
  • 北京网站制作多少钱一个新手怎么做推广
  • 如何注销网站备案怎么被百度收录
  • 建筑方案设计网站网络营销师官网
  • 心雨在线高端网站建设网页设计西安seo顾问