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

河南省建设工程一体化平台网络优化的流程

河南省建设工程一体化平台,网络优化的流程,织梦新闻网站模板下载,网站数据库太大搬家还原500错误在Seata中,有4种分布式事务实现方案 XA、AT、TCC、Saga 其中XA利用了数据库的分布式事务特性,AT相当于框架去控制事务回滚。TCC手写三个方法,saga手写两个方法。 AT的性能和编写比较折中,是最常用的一种。TCC一些视频教程中介绍…

在Seata中,有4种分布式事务实现方案

XA、AT、TCC、Saga

其中XA利用了数据库的分布式事务特性,AT相当于框架去控制事务回滚。TCC手写三个方法,saga手写两个方法。

AT的性能和编写比较折中,是最常用的一种。TCC一些视频教程中介绍了单表单字段加中间表的方式存储过程数据,对于一次操作多个主子表数据的示例目前实现还是太繁琐了。

根据官方实例和相关视频简单写了下代码。

对于配置,能用默认的用默认,有示例配置的优先抄示例配置

1.加依赖

        <!-- 版本对应关系Alibaba 2021.0.5 对应 Seata 1.6.1https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E这里依赖不是 spring-cloud-alibaba-seata--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-seata</artifactId><version>2021.0.5.0</version></dependency>

这里alibaba版本是2021.0.5所以spring-cloud-starter-alibaba-seata也用这个版本,注意版本对应

2.写配置

seata:registry:type: nacosnacos:application: seata-serverserver-addr: 127.0.0.1:8848group: SEATA_GROUPcluster: default#事务组tx-service-group:  default_tx_groupservice:#事务组和集群名称映射vgroup-mapping:default_tx_group: defaultdata-source-proxy-mode: AT

注意,这里需要先配置好nacos和seata服务端,seata服务端早期是json配置的,新版的是yaml配置

seata服务端配置application.yml

#  Copyright 1999-2019 Seata.io Group.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.server:port: 7091spring:application:name: seata-serverlogging:config: classpath:logback-spring.xmlfile:path: ${log.home:${user.home}/logs/seata}extend:logstash-appender:destination: 127.0.0.1:4560kafka-appender:bootstrap-servers: 127.0.0.1:9092topic: logback_to_logstashconsole:user:username: seatapassword: seata
seata:config:# support: nacos, consul, apollo, zk, etcd3type: fileregistry:# support: nacos, eureka, redis, zk, consul, etcd3, sofatype: nacosnacos:application: seata-serverserver-addr: 127.0.0.1:8848group: SEATA_GROUPnamespace:cluster: defaultusername:password:context-path:store:# support: file 、 db 、 redismode: file
#  server:
#    service-port: 8091 #If not configured, the default is '${server.port} + 1000'security:secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017tokenValidityInMilliseconds: 1800000ignore:urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.jpeg,/**/*.ico,/api/v1/auth/login

3.写代码

将主调用的方法注解@Transactional改为@GlobalTransactional,其他微服务方法无需更改。

完整代码见顶部

http://www.zhongyajixie.com/news/712.html

相关文章:

  • 怎样开个人网站东莞建设企业网站公司
  • 室内设计师前景怎么样电影站的seo
  • 九江做网站哪家好如何推广网站
  • 广州网站推广奋醴陵网站制作
  • visual studio做的网站兰州seo推广
  • 温州市网站建设如何提高搜索引擎优化
  • 手机网站建设的整体流程图不受国内限制的浏览器
  • 个人可以建设农资网站吗注册域名查询网站官网
  • 电子商务之网站建设关键词百度网盘
  • 惠州哪家做网站比较好百度seoo优化软件
  • 做网站每年都要费用的吗百度竞价品牌广告
  • 忻州市建设厅网站首页世界羽联巡回赛总决赛
  • 一般网站用什么做的长沙seo关键词
  • 怎么做一个商城网站宁波seo网络推广报价
  • 幼儿园主题网络图设计 王菲成都网站seo费用
  • 怎么查看网站是否降权seo外包杭州
  • 建设b2c网站谷歌google浏览器
  • 易班网站建设基础推广普通话的意义50字
  • 蓝色网站模版做外贸网站哪家公司好
  • 国外网站设计网站查域名注册详细信息查询
  • wordpress公众号文章分类有没有免费的seo网站
  • xml网站模板郑州网站建设十大公司
  • 制作网站找云优化运营网站
  • 擦边球做网站挣钱互联网营销
  • 安阳吧 百度贴吧搜索引擎优化实训报告
  • 厦门网红桥seo关键词排名教程
  • 深圳靠谱网站建设公司免费的网站申请
  • 找订单平台哪个好广州优化疫情防控措施
  • 全包装修桂林seo
  • 做专业的精品套图网站今天特大新闻最新消息