1. 概述
Seata API 分为两大类:High-Level API 和 Low-Level API :
- High-Level API :用于事务边界定义、控制及事务状态查询。
- Low-Level API :用于控制事务上下文的传播。
2. High-Level API
2.1 GlobalTransaction
全局事务:包括开启事务、提交、回滚、获取当前状态等方法。
public interface GlobalTransaction {
/**
* 开启一个全局事务(使用默认的事务名和超时时间)
*/
void begin() throws TransactionException;
/**
* 开启一个全局事务,并指定超时时间(使用默认的事务名)
*/
void begin(int timeout) throws TransactionException;
/**
* 开启一个全局事务,并指定事务名和超时时间
*/
void begin(int timeout, String name) throws TransactionException;
/**
* 全局提交
*/
void commit() throws TransactionException;
/**
* 全局回滚
*/
void rollback() throws TransactionException;
/**
* 获取事务的当前状态
*/
GlobalStatus getStatus() throws TransactionException;
/**
* 获取事务的 XID
*/
String getXid();
}