Code Monkey home page Code Monkey logo

bytetcc's Introduction

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
<dependency>
	<groupId>org.bytesoft</groupId>
	<artifactId>bytetcc-supports-springcloud</artifactId>
	<version>0.5.7</version>
</dependency>
1.1.2. dubbo
<dependency>
	<groupId>org.bytesoft</groupId>
	<artifactId>bytetcc-supports-dubbo</artifactId>
	<version>0.5.7</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

  • 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
  • support Spring Cloud
  • provide solutions for service idempotence in framework layer

4. Contact Me

If you have any questions or comments regarding this project, please feel free to contact me at:

  1. send mail to bytefox#126.com OR
  2. add Tecent QQ group 537445956/606453172/383515467

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

bytetcc's People

Contributors

liuyangming avatar liuyangming9f avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.