ByteTCC 分布式事务管理器

程序名称:ByteTCC

授权协议: LGPL

操作系统: 跨平台

开发语言: Java

ByteTCC 介绍


ByteTCC是一个基于TCC(Try/Confirm/Cancel)机制的分布式事务管理器。兼容JTA,可以很好的与spring容器进行集成。

一、快速入门

1.1. 加入maven依赖

<dependency>
    <groupId>org.bytesoft</groupId>
    <artifactId>bytetcc-supports-springcloud</artifactId>
    <version>0.4.0-rc1</version>
</dependency>
<dependency>
    <groupId>org.bytesoft</groupId>
    <artifactId>bytetcc-supports-dubbo</artifactId>
    <version>0.4.0-rc1</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特性

四、服务质量

4.1. 故障恢复

任意时刻任意故障
包括但不限于:业务系统/RDBS服务器宕机;网络故障;断电等)造成的事务中断,ByteTCC均有相应机制予以恢复,保证全局事务的最终一致性。

4.2. 幂等性

ByteTCC 在框架层面提供对Confirm/Cancel业务逻辑的幂等性保障 ,业务系统仅需关注自身业务本身,无需为幂等性问题而烦恼。

五、建议及改进

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

ByteTCC 官网

https://gitee.com/bytesoft/ByteTCC

相关编程语言

BlazeDS 是一个基于服务器的Java 远程控制(remoting...
OVal 是一个可扩展的Java对象数据验证框架,验证的规...
Volta 是一套开发工具,专为开发分布式、实时系统应...
OpenDDS 是一个开源的 C++ 实现的 对象管理组织 OMG...
JADE (Java Agent DEvelopment Framework) 是一个完...
FastMM ,在D2006和2007中已代替了原来的内存管理器。