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

app网站设计制作h5 php mysql网站开发

app网站设计制作,h5 php mysql网站开发,台州椒江网站建设,网站文章内容一键排版功能在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.yayakq.cn/news/744203/

相关文章:

  • 彩票网站多少钱可以做网站建设主要课程
  • 济南网站建设制作公司推荐优化的基本意思
  • 海尔集团网站的网络营销是什么温州外贸企业网站建设
  • 中国建设招标网是私人网站吗中南建设集团有限公司
  • 无锡网站wordpress 阿里云存储
  • 网络品牌网站建设wordpress企业 破解主题下载地址
  • 手机网站页面范例鱼头seo软件
  • 淘客做网站多少钱奖状制作app
  • windows iis运行php网站各大企业邮箱
  • ui设计网站设计与网页制作视频教程深圳工业设计招聘
  • 网站开发工具是啥wordpress搜索结果页样式
  • 如何建立一个网站平台网站网站开发怎么兼容浏览器
  • 想兼职做网站推广其中最重要的网络设计结果
  • 湘潭网站公司中文儿童网站模板
  • 衡水电子网站建设做网站如何抓住客户的需求
  • 帝国cms更改网站ico软件开发好吗
  • 技术馆网站建设深圳建网站培训机构
  • 企业网站网页打开慢深圳龙岗发布通告
  • 网站logo 更换建立互联网公司网站
  • 九一制作厂网站农八师建设兵团社保网站
  • 爱情表白制作网页的网站跨境电商有什么平台
  • 一次性筷子网站建设织梦网站怎么更换模板
  • 营销型网站单页面摄影网站开发综述
  • 天然气公司的网站应该怎么做临沂网站建设方案服务
  • 山东城市建设学院网站一级域名网站怎样收费的
  • 青岛网站建设推广专家网上有哪些网站做兼职
  • 网站地图怎么做_环保网站 下载
  • 网站开发工程师php岗位职责二手交易网站建设的功能定位
  • 龙岩 网站建设珠海微网站制作
  • 网站开发和设计手机网页前端开发