• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

ByteTCC: ByteTCC Transaction Manager旨在提供一个兼容JTA的基于TCC机制的分布式事务 ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

ByteTCC

开源软件地址:

https://gitee.com/bytesoft/ByteTCC

开源软件介绍:

ByteTCC是一个基于TCC(Try/Confirm/Cancel)机制的分布式事务管理器。兼容JTA,可以很好的与EJB、Spring等容器(本文档下文说明中将以Spring容器为例)进行集成。

一、快速入门

1.1. 加入maven依赖

1.1.1. 使用Spring Cloud
<dependency>	<groupId>org.bytesoft</groupId>	<artifactId>bytetcc-supports-springcloud</artifactId>	<version>0.5.10</version></dependency>
1.1.2. 使用dubbo
<dependency>	<groupId>org.bytesoft</groupId>	<artifactId>bytetcc-supports-dubbo</artifactId>	<version>0.5.10</version></dependency>

1.2. 编写业务服务

@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. 编写confirm服务

@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. 编写cancel服务

@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);	}}

二、文档 & 样例

三、ByteTCC特性

  • 1、支持Spring容器的声明式事务管理;
  • 2、支持普通事务、TCC事务、saga事务等事务机制;
  • 3、支持多数据源、跨应用、跨服务器等分布式事务场景;
  • 4、支持长事务;
  • 5、支持dubbo服务框架;
  • 6、支持spring cloud;
  • 7、提供框架层面的幂等性保障;

四、历史版本

4.1. v0.3.x

4.2. v0.2.0-alpha

4.3. v0.1.2

4.4. v0.1

五、建议及改进

若您有任何建议,可以通过1)加入qq群537445956/606453172/383515467向群主提出,或2)发送邮件至bytefox#126.com向我反馈。本人承诺,任何建议都将会被认真考虑,优秀的建议将会被采用,但不保证一定会在当前版本中实现。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap