# ByteTCC **Repository Path**: java20150326/ByteTCC ## Basic Information - **Project Name**: ByteTCC - **Description**: ByteTCC Transaction Manager旨在提供一个兼容JTA的基于TCC机制的分布式事务管理器。用户手册: https://github.com/liuyangming/ByteTCC/wiki - **Primary Language**: Java - **License**: LGPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 56 - **Created**: 2018-03-21 - **Last Updated**: 2021-11-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README  **ByteTCC** is an implementation of Distributed Transaction Manager, based on Try-Confirm-Cancel (TCC) mechanism. **ByteTCC** is comptible with JTA and could be seamlessly integrated with Spring and other Java containers. ## 1. Quick Start #### 1.1 Add maven depenency ###### 1.1.1. Spring Cloud ```xml org.bytesoft bytetcc-supports-springcloud 0.4.7 ``` ###### 1.1.2. dubbo ```xml org.bytesoft bytetcc-supports-dubbo 0.4.7 ``` #### 1.2 Compose a business service ```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 Compose a confirm service ```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 Compose a cancel service ```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. Documentation & Samples * [Document](https://github.com/liuyangming/ByteTCC/wiki) * [Sample](https://github.com/liuyangming/ByteTCC-sample) ## 3. Features * 1. support declarative transaction management * 2. support normal transaction, TCC transaction, compensating service transaction * 3. support distributed transaction scenarios. e.g. multi-datasource, cross-applications and cross-servers transaction * 4. support long live transaction * 5. support Dubbo framework * 6. provide solutions for service idempotence in framework layer ## 4. History #### v0.4.x * Link:[https://github.com/liuyangming/ByteTCC/tree/0.4.x](https://github.com/liuyangming/ByteTCC/tree/0.4.x) * Doc:[https://github.com/liuyangming/ByteTCC/wiki](https://github.com/liuyangming/ByteTCC/wiki) #### v0.3.x * Link:[https://github.com/liuyangming/ByteTCC/tree/0.3.x](https://github.com/liuyangming/ByteTCC/tree/0.3.x) * Doc:[https://github.com/liuyangming/ByteTCC/wiki](https://github.com/liuyangming/ByteTCC/wiki) #### v0.2.0-alpha * Link:[http://code.taobao.org/p/openjtcc](http://code.taobao.org/p/openjtcc) * Doc:[http://code.taobao.org/p/openjtcc/wiki/index/](http://code.taobao.org/p/openjtcc/wiki/index/) #### v0.1.2 * Link:[http://code.google.com/p/bytetcc](http://code.google.com/p/bytetcc) #### v0.1 * Link:[http://pan.baidu.com/s/1hq3ffxU](http://pan.baidu.com/s/1hq3ffxU) ## 5. Contact Me If you have any questions or comements regarding this project, please feel free to contact me at: 1. send mail to _[bytefox@126.com](bytefox@126.com)_ ~OR~ 2. add Tecent QQ group 537445956/606453172 We will review all the suggestions and implement good ones in future release.