百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
B

ByteTCC

> 后端框架
开源

ByteTCC 是一个基于TCC(Try/Confirm/Cancel)机制的分布式事务管理器。它兼容JTA规范。用户指南:https://git

2.9K stars0 点赞1 次浏览
访问官网GitHub

工具介绍

ByteTCC 是一个基于TCC(Try/Confirm/Cancel)机制的分布式事务管理器。它兼容JTA规范。用户指南:https://git

ByteTCC 是一个基于 Try-Confirm-Cancel(TCC)机制的分布式事务管理器实现。

ByteTCC 兼容 JTA,并且可以与 Spring 及其他 Java 容器无缝集成。

1. 快速开始

1.1 添加 Maven 依赖

1.1.1. Spring Cloud
xml
<dependency>
	<groupId>org.bytesoft</groupId>
	<artifactId>bytetcc-supports-springcloud</artifactId>
	<version>0.5.12</version>
</dependency>
1.1.2. Dubbo
xml
<dependency>
	<groupId>org.bytesoft</groupId>
	<artifactId>bytetcc-supports-dubbo</artifactId>
	<version>0.5.12</version>
</dependency>

1.2 编写业务服务

java
@Service("accountService")
@Compensable(
  interfaceClass = IAccountService.class 
, confirmableKey = "accountServiceConfirm"
, cancellableKey = "accountServiceCancel"
)
public class AccountServiceImpl implements IAccountService {

	@Resource(name = "jdbcTemplate")
	private JdbcTemplate jdbcTemplate;

	@Transactional
	public void increaseAmount(String accountId, double amount) throws ServiceException {
	    this.jdbcTemplate.update("update tb_account set frozen = frozen + ? where acct_id = ?", amount, acctId);
	}

}

1.3 编写确认服务

java
@Service("accountServiceConfirm")
public class AccountServiceConfirm implements IAccountService {

	@Resource(name = "jdbcTemplate")
	private JdbcTemplate jdbcTemplate;

	@Transactional
	public void increaseAmount(String accountId, double amount) throws ServiceException {
	    this.jdbcTemplate.update("update tb_account set amount = amount + ?, frozen = frozen - ? where acct_id = ?", amount, amount, acctId);
	}

}

1.4 编写取消服务

java
@Service("accountServiceCancel")
public class AccountServiceCancel implements IAccountService {

	@Resource(name = "jdbcTemplate")
	private JdbcTemplate jdbcTemplate;

	@Transactional
	public void increaseAmount(String accountId, double amount) throws ServiceException {
	    this.jdbcTemplate.update("update tb_account set frozen = frozen - ? where acct_id = ?", amount, acctId);
	}

}

2. 文档与示例

  • 文档
  • 示例

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Javadistributed-transactiondubbojtaspring-cloud

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类后端框架
定价开源

> 相关工具

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架