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.
<dependency>
<groupId>org.bytesoft</groupId>
<artifactId>bytetcc-supports-springcloud</artifactId>
<version>0.4.13</version>
</dependency>
<dependency>
<groupId>org.bytesoft</groupId>
<artifactId>bytetcc-supports-dubbo</artifactId>
<version>0.4.13</version>
</dependency>
@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);
}
}
@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);
}
}
@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);
}
}
-
- support declarative transaction management
-
- support normal transaction, TCC transaction, compensating service transaction
-
- support distributed transaction scenarios. e.g. multi-datasource, cross-applications and cross-servers transaction
-
- support long live transaction
-
- support Dubbo framework
-
- provide solutions for service idempotence in framework layer
- Link:https://github.com/liuyangming/ByteTCC/tree/0.4.x
- Doc:https://github.com/liuyangming/ByteTCC/wiki
- Link:https://github.com/liuyangming/ByteTCC/tree/0.3.x
- Doc:https://github.com/liuyangming/ByteTCC/wiki
If you have any questions or comements regarding this project, please feel free to contact me at:
- send mail to [email protected]
OR - add Tecent QQ group 537445956/606453172
We will review all the suggestions and implement good ones in future release.