当前位置:网站首页>Distributed transaction Seata
Distributed transaction Seata
2022-07-26 19:08:00 【Yang Fan's blog】
Record based seata The official website is set up locally seata The process of
download seata Software news (Releases · seata/seata · GitHub) Unzip it .
start-up seata service
sh seata-server.sh -p 8091 -h 127.0.0.1 -m file
Download the examples provided on the official website (GitHub - seata/seata-samples: seata-samples)
If you use zk For the registry , Start locally first zk service , Then modify the registry of the following four configuration files as zk

<dubbo:registry address="zookeeper://127.0.0.1:2181" />
Create a new one seata library , And initialize the structure of the following five tables in the table

-- Notice here 0.3.0+ Add unique index ux_undo_log
CREATE TABLE `undo_log`
(
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`branch_id` bigint(20) NOT NULL,
`xid` varchar(100) NOT NULL,
`context` varchar(128) NOT NULL,
`rollback_info` longblob NOT NULL,
`log_status` int(11) NOT NULL,
`log_created` datetime NOT NULL,
`log_modified` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `stock_tbl`;
CREATE TABLE `stock_tbl`
(
`id` int(11) NOT NULL AUTO_INCREMENT,
`commodity_code` varchar(255) DEFAULT NULL,
`count` int(11) DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY (`commodity_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `order_tbl`;
CREATE TABLE `order_tbl`
(
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` varchar(255) DEFAULT NULL,
`commodity_code` varchar(255) DEFAULT NULL,
`count` int(11) DEFAULT 0,
`money` int(11) DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `account_tbl`;
CREATE TABLE `account_tbl`
(
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` varchar(255) DEFAULT NULL,
`money` int(11) DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;To start, respectively, :
1、DubboAccountServiceStarter;
2、DubboStorageServiceStarter;
3、DubboOrderServiceStarter
And then it runs again DubboBusinessTester You can see the test results
Remark: function demo Problems encountered in
1、 The following error is reported because spring and com.alibaba.spring Version compatibility issues , Need to add one version
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'referenceAnnotationBeanPostProcessor': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.setClassValuesAsString(Z)V
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'referenceAnnotationBeanPostProcessor': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.setClassValuesAsString(Z)V
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1270)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1164)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:207)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:707)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:144)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:95)
at io.seata.samples.dubbo.starter.DubboStockServiceStarter.main(DubboStockServiceStarter.java:32)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.setClassValuesAsString(Z)V
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:184)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1262)
... 13 more
Caused by: java.lang.NoSuchMethodError: org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.setClassValuesAsString(Z)V
at org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.<init>(ReferenceAnnotationBeanPostProcessor.java:106)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:172)
... 15 more
Solution Add one more <version>1.0.11</version>
<dependency>
<groupId>com.alibaba.spring</groupId>
<artifactId>spring-context-support</artifactId>
<version>1.0.11</version>
</dependency>2、 Because my local database uses mysql8, Therefore, the following modifications are required
- Modify the driver
jdbc.stock.driver=com.mysql.cj.jdbc.Driver
- modify pom The dependence in is
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.16</version>
</dependency>边栏推荐
- What aspects should be considered in the selection of MES system?
- Redis learning notes-2. Use of the client
- JS刷题计划——链表
- Likeshop takeout order system is open source, 100% open source, no encryption
- PMP candidates must read, and the epidemic prevention requirements for the exam on July 30 are here
- 2022 welder (elementary) operation certificate examination question bank and simulation examination
- MES系统最全介绍来了
- NFT digital collection development: digital collections help enterprise development
- LeetCode简单题之装满杯子需要的最短总时长
- 2022t elevator repair examination questions and online simulation examination
猜你喜欢

NFT digital collection system development: fellow uncle first promoted the blessing series digital collection, which will be sold out immediately

NFT digital collection system development: sold out when online, and netizens "spike" Digital Collections

The diagram of user login verification process is well written!

多商户商城系统功能拆解16讲-平台端会员成长值记录

Leetcode simple question: the minimum total time required to fill a cup

Unity 农场 2 —— 种植系统

Learn UML system modeling from me

2022g1 industrial boiler stoker certificate question bank and simulation examination

2022年焊工(初级)操作证考试题库及模拟考试

Multi thread learning notes -1.cas
随机推荐
Is it safe to apply for public REITs account by mobile phone?
简述MES系统的11大核心功能模块
2022年云商店联合营销市场发展基金(MDF)介绍
支持代理直连Oracle数据库,JumpServer堡垒机v2.24.0发布
Racher deploys kubernetes cluster
How many pairs can an array of leetcode simple questions form
Paged query design of scenarios
NFT digital collection system development: sold out when online, and netizens "spike" Digital Collections
Database expansion can also be so smooth, MySQL 100 billion level data production environment expansion practice
微软默默给 curl 捐赠一万美元,半年后才通知
多线程学习笔记-1.CAS
Likeshop takeout order system is open source, 100% open source, no encryption
flex布局
分布式事务-seata
2022年焊工(初级)操作证考试题库及模拟考试
MySQL学习笔记-2.如何提高sql语句的查询性能
LeetCode简单题之装满杯子需要的最短总时长
Accused of excessive patent licensing fees! The U.S. Court ruled that Qualcomm violated the antitrust law: Qualcomm's share price fell 10.86%!
2022 mobile crane driver test questions simulation test platform operation
Simulated 100 questions and simulated examination of refrigeration and air conditioning equipment operation examination in 2022