zoukankan      html  css  js  c++  java
  • 谷粒商城Seata(四十一)

    283-289

    这章节主要讲的就是seata及一些分布式事务的概念。

    之前的博客也有写过,可以查看:https://www.cnblogs.com/dalianpai/category/1591258.html

    不过用的方式还是不太一样,其中就包括数据源的创建和一些配置文件,还有当和mybatisplus整合的时候,我本地是报错的。

    主要的配置:

    /**
     * @author WGR
     * @create 2020/8/5 -- 21:48
     */
    @Configuration
    public class MySeataConfig {
    
        @Autowired
        DataSourceProperties dataSourceProperties;
    
        @Bean
        public DataSource dataSource(DataSourceProperties dataSourceProperties){
            HikariDataSource dataSource = dataSourceProperties.initializeDataSourceBuilder().type(HikariDataSource.class).build();
            if(StringUtils.hasText(dataSourceProperties.getName())){
                dataSource.setPoolName(dataSourceProperties.getName());
            }
            return new DataSourceProxy(dataSource);
        }
    
    }
    

    然后在配置文件都要放一份在项目中。

    image-20200805225343607

    服务端的开启:

    [root@database conf]# cd ../bin/
    [root@database bin]# ll
    total 8
    -rw-r--r-- 1  502 games 3180 Jul 15  2019 seata-server.bat
    -rwxr-xr-x 1  502 games 3709 Jul 15  2019 seata-server.sh
    drwxr-xr-x 2 root root    23 Aug  5 09:16 sessionStore
    [root@database bin]# nohup sh seata-server.sh &> /dev/null &
    [1] 4646
    [root@database bin]# netstat -nltp
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1049/sshd
    tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1223/master
    tcp6       0      0 :::6379                 :::*                    LISTEN      1722/docker-proxy
    tcp6       0      0 :::22                   :::*                    LISTEN      1049/sshd
    tcp6       0      0 ::1:25                  :::*                    LISTEN      1223/master
    tcp6       0      0 :::8091                 :::*                    LISTEN      4646/java
    tcp6       0      0 :::3306                 :::*                    LISTEN      1734/docker-proxy
    

    当开始测试的时候,批量插入就直接报错,修改for循环就可以了。

    image-20200805225552809

    image-20200805232925770

    发现他有一个判断,当在全局事务中,为批量插入的话,就有异常

    image-20200806002200019

  • 相关阅读:
    MYSQL导入,导出命令。
    MySQL修改,表结构大幅修改
    Ajax
    js和jQuery的日常
    freemarker 分页取值
    Timer定时任务
    汉字相似度比较
    读取Properties键值对
    Python+requests+unittest+excel实现接口自动化测试框架
    Android App 压力测试方法(Monkey)
  • 原文地址:https://www.cnblogs.com/dalianpai/p/13443711.html
Copyright © 2011-2022 走看看