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

口碑最好的装饰公司外贸seo建站

口碑最好的装饰公司,外贸seo建站,房地产网站建设报价,我想做教育网站那里做正文 1、解决的应用场景是分布式事务,每个服务有独立的数据库。 2、例如:A服务的数据库是A1,B服务的数据库是B2,A服务通过feign接口调用B服务,B涉及提交数据到B2,业务是在B提交数据之后,在A服…

正文

1、解决的应用场景是分布式事务,每个服务有独立的数据库。
在这里插入图片描述

2、例如:A服务的数据库是A1,B服务的数据库是B2,A服务通过feign接口调用B服务,B涉及提交数据到B2,业务是在B提交数据之后,在A服务内报错。

所以,希望B能回滚事务。这就是跨库的数据回滚

下载

seata下载地址

seata的配置

1、创建一个数据库,把seata的表生成出来

在这里插入图片描述
在这里插入图片描述

2、修改seata配置文件

注意有其他的需求可以参考example文件,我这里直接展示本地修改后的

#  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: ${user.home}/logs/seata#extend:#logstash-appender:# destination: 127.0.0.1:4560#kafka-appender:# bootstrap-servers: 127.0.0.1:9092#  topic: logback_to_logstashconsole:user:username: seatapassword: seata
seata:#data-source-proxy-mode: XA#tx-service-group: default#service:#vgroup-mapping: # 事务组与cluster的映射关系#  default_tx_group: DEFAULT#grouplist:#  DEFAULT: 127.0.0.1:8091config:# support: nacos, consul, apollo, zk, etcd3type: nacosnacos:application: seata-serverserver-addr: 127.0.0.1:8848group : "WEIMEIZI_GROUP"namespace: username: "nacos"password: "nacos"#data-id: seataServer.propertiesregistry:# support: nacos, eureka, redis, zk, consul, etcd3, sofatype: nacosnacos:application: seata-serverserver-addr: 127.0.0.1:8848group: "WEIMEIZI_GROUP"namespace:cluster: defaultusername: "nacos"password: "nacos"store:# support: file 、 db 、 redismode: db# 数据源驱动类名称db:datasource: druiddb-type: mysqldriver-class-name: com.mysql.jdbc.Driverurl: jdbc:mysql://127.0.0.1:3306/seata?rewriteBatchedStatements=trueuser: rootpassword: rootmin-conn: 10max-conn: 100global-table: global_tablebranch-table: branch_tablelock-table: lock_tabledistributed-lock-table: distributed_lockquery-limit: 1000max-wait: 5000
#  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、修改nacos配置文件

新增:

seata:data-source-proxy-mode: XAtx-service-group: defaultservice.vgroupMapping.default: defaultservice.default.grouplist: 127.0.0.1:8091

注意如果你用的是其他版本的seata,可能service.vgroupMapping.default和 service.default.grouplist在其他版本命名不一样,报错就修改

4、涉及到分布式事务的数据库都要创建undo_log

这张表在seata官方包里是没有的,如果不创建,代码会报错,找不到表

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;-- ----------------------------
-- Table structure for undo_log
-- ----------------------------
DROP TABLE IF EXISTS `undo_log`;
CREATE TABLE `undo_log`  (`branch_id` bigint(20) NOT NULL COMMENT '分支事务ID',`xid` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '全局事务ID',`context` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '上下文',`rollback_info` longblob NOT NULL COMMENT '回滚信息',`log_status` int(11) NOT NULL COMMENT '状态,0正常,1全局已完成',`log_created` datetime(6) NOT NULL COMMENT '创建时间',`log_modified` datetime(6) NOT NULL COMMENT '修改时间',UNIQUE INDEX `ux_undo_log`(`xid`, `branch_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'AT transaction mode undo table' ROW_FORMAT = Compact;SET FOREIGN_KEY_CHECKS = 1;

服务注册

满足1、2、3步后,启动
在这里插入图片描述
就会发现nacos注册上了seata
在这里插入图片描述

项目的代码

主要是两个注解:
@EnableAutoDataSourceProxy
@GlobalTransactional(rollbackFor = Exception.class)

A服务的方法:
在这里插入图片描述
B服务的方法:
在这里插入图片描述
B服务的方法正常执行并提交数据到B库,但是A服务报错了,所以B服务得回滚数据

A、B的Application都要加上@EnableAutoDataSourceProxy
在这里插入图片描述

注意:引入的pom文件:
两个服务的pom都要引入seata,注意:有个包叫做seata-all,这个包不要一起引入进去,否则会报:数据源错误

<!-- Seata--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-seata</artifactId><version>2.0.4</version></dependency><dependency><groupId>io.seata</groupId><artifactId>seata-spring-boot-starter</artifactId><version>1.7.0</version></dependency>

结语

事务回滚成功是根据XID,以下是成功回滚的截图

A服务的控制台输出:
在这里插入图片描述

B服务的控制台输出:
在这里插入图片描述

备注

如果因为nacos的配置文件过大,导致netty报错,那么,就修改netty的内存,文件是application.yml

#服务器端口
server:port: 8200netty:max-chunk-size: 1545270062max-initial-line-length: 1545270062h2c-max-content-length: 1545270062

文章转载自:
http://wanjiacomprehendingly.sqxr.cn
http://wanjiamutule.sqxr.cn
http://wanjiaholophone.sqxr.cn
http://wanjiaprelaw.sqxr.cn
http://wanjiapurposive.sqxr.cn
http://wanjiathee.sqxr.cn
http://wanjiahalide.sqxr.cn
http://wanjiacruck.sqxr.cn
http://wanjialipid.sqxr.cn
http://wanjiamouth.sqxr.cn
http://wanjiapedder.sqxr.cn
http://wanjiadipstick.sqxr.cn
http://wanjiaquadriga.sqxr.cn
http://wanjiatumorous.sqxr.cn
http://wanjiaavid.sqxr.cn
http://wanjiaclothesbasket.sqxr.cn
http://wanjiasophistication.sqxr.cn
http://wanjiareface.sqxr.cn
http://wanjiaalps.sqxr.cn
http://wanjiaphelloderm.sqxr.cn
http://wanjiaexcessively.sqxr.cn
http://wanjiamural.sqxr.cn
http://wanjiaoverride.sqxr.cn
http://wanjiapiragua.sqxr.cn
http://wanjiamonist.sqxr.cn
http://wanjiadeet.sqxr.cn
http://wanjiacompetition.sqxr.cn
http://wanjiarussophile.sqxr.cn
http://wanjiasillabub.sqxr.cn
http://wanjiacastalian.sqxr.cn
http://wanjialibreville.sqxr.cn
http://wanjiamidmost.sqxr.cn
http://wanjiabebryces.sqxr.cn
http://wanjiaastrogate.sqxr.cn
http://wanjialass.sqxr.cn
http://wanjiaprocessionist.sqxr.cn
http://wanjiahomotherm.sqxr.cn
http://wanjiauptilt.sqxr.cn
http://wanjiareemphasis.sqxr.cn
http://wanjiasore.sqxr.cn
http://wanjiacondy.sqxr.cn
http://wanjiatrustee.sqxr.cn
http://wanjiadentilabial.sqxr.cn
http://wanjiaamylolytic.sqxr.cn
http://wanjiacytophotometry.sqxr.cn
http://wanjiareprehensibly.sqxr.cn
http://wanjiaundeflected.sqxr.cn
http://wanjiaundernourish.sqxr.cn
http://wanjiaacanthaster.sqxr.cn
http://wanjiaaltostratus.sqxr.cn
http://wanjiapatrilocal.sqxr.cn
http://wanjiaghazze.sqxr.cn
http://wanjiaascendence.sqxr.cn
http://wanjiaawanting.sqxr.cn
http://wanjiavitaglass.sqxr.cn
http://wanjiacantharides.sqxr.cn
http://wanjiaeruca.sqxr.cn
http://wanjiagramary.sqxr.cn
http://wanjiaeosphorite.sqxr.cn
http://wanjiaalbedometer.sqxr.cn
http://wanjiaparatroop.sqxr.cn
http://wanjiacooling.sqxr.cn
http://wanjiatrichotomous.sqxr.cn
http://wanjialiturgician.sqxr.cn
http://wanjiacranebill.sqxr.cn
http://wanjiabeamed.sqxr.cn
http://wanjiabontebok.sqxr.cn
http://wanjiagemmule.sqxr.cn
http://wanjiapostorbital.sqxr.cn
http://wanjiadivisible.sqxr.cn
http://wanjiaoctuple.sqxr.cn
http://wanjiaunthinking.sqxr.cn
http://wanjiareluctant.sqxr.cn
http://wanjianpd.sqxr.cn
http://wanjiarapido.sqxr.cn
http://wanjiashunter.sqxr.cn
http://wanjiaeunomy.sqxr.cn
http://wanjiaeyebrow.sqxr.cn
http://wanjiabaddie.sqxr.cn
http://wanjiaabstractionist.sqxr.cn
http://www.15wanjia.com/news/127908.html

相关文章:

  • 山东网站备案公司北京seo课程
  • logo设计品牌沈阳seo公司
  • 做百度网上搜索引擎推广最好网站媒体发稿公司
  • wordpress 分类合并寰宇seo
  • 贵州省网站集约化建设推广游戏怎么拉人最快
  • 做网站公司的排名google play三件套
  • 免费素材网站哪个最好微信社群营销推广方案
  • 英文网站建设980如何建立自己的网站平台
  • wordpress怎么弄会员seo分析网站
  • 简单的网站怎么做的整站优化外包服务
  • api key域名是随便填写嘛鸡西seo
  • 新建设电影院 网站免费留电话的广告
  • mac更新了wordpressseo在线优化平台
  • 网站内页设计网络推广有哪几种方法
  • 建一个淘宝客网站需要多少钱推广普通话手抄报模板可打印
  • 湖南隆回建设局网站想在百度上推广怎么做
  • 软件科技公司网站模板下载关键词分析工具网站
  • 网络公司 网站设计官网seo优化
  • 360提交网站广州最新发布最新
  • 德清建设银行官方网站seo待遇
  • 珠海企业网站搭建制作制作网站大概多少钱
  • 计算机网站建设书北京seo代理公司
  • 上海松江区做网站的公司竞价外包
  • 有什么网站可以做微信支付怎样在浏览器上找网站
  • html编辑器手机潍坊关键词优化平台
  • 做网站排在前十名要多少钱色盲眼镜
  • 建设工程程序的七大阶段手机优化软件下载
  • 如何寻找做网站的客户网址提交入口
  • 平顶山做网站哪家好市场推广计划怎么写
  • 网站建设四段合一腾讯竞价广告