Skip to content

Latest commit

 

History

History
110 lines (78 loc) · 3.06 KB

README-en.md

File metadata and controls

110 lines (78 loc) · 3.06 KB

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

<dependency>
	<groupId>org.bytesoft</groupId>
	<artifactId>bytetcc-supports-dubbo</artifactId>
	<version>0.4.0-beta3</version>
</dependency>

1.2 Compose a business service

@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

@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

@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

3. Features

    1. support declarative transaction management
    1. support normal transaction, TCC transaction, compensating service transaction
    1. support distributed transaction scenarios. e.g. multi-datasource, cross-applications and cross-servers transaction
    1. support long live transaction
    1. support Dubbo framework
    1. provide solutions for service idempotence in framework layer

4. History

v0.2.0-alpha

v0.1.2

v0.1

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 OR
  2. add Tecent QQ group 537445956

We will review all the suggestions and implement good ones in future release.