Logo
Seata Transaction

Seata Transaction #

Start Seata Transaction #

Follow the steps in seata-work-shop to download and start the Seata server.

Create log table #

Create the undo_log table in each sharding database instance (take MySQL as an example).

CREATE TABLE IF NOT EXISTS `undo_log`
(
  `id`            BIGINT(20)   NOT NULL AUTO_INCREMENT COMMENT 'increment id',
  `branch_id`     BIGINT(20)   NOT NULL COMMENT 'branch transaction id',
  `xid`           VARCHAR(100) NOT NULL COMMENT 'global transaction id',
  `context`       VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
  `rollback_info` LONGBLOB     NOT NULL COMMENT 'rollback info',
  `log_status`    INT(11)      NOT NULL COMMENT '0:normal status,1:defense status',
  `log_created`   DATETIME     NOT NULL COMMENT 'create datetime',
  `log_modified`  DATETIME     NOT NULL COMMENT 'modify datetime',
  PRIMARY KEY (`id`),
  UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  DEFAULT CHARSET = utf8 COMMENT ='AT transaction mode undo table';

Modify Configuration #

Add seata.conf file to classpath.

client {
    application.id = example    ## 应用唯一主键
    transaction.service.group = my_test_tx_group   ## 所属事务组
}

Modify Seata’s file.conf and registry.conf files according to actual scenarios.