Coder Social home page Coder Social logo

xingfudeshi / bytetcc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from liuyangming/bytetcc

0.0 1.0 0.0 1.16 MB

ByteTCC是一个兼容JTA规范的基于TCC机制的分布式事务管理器。用户手册:https://github.com/liuyangming/ByteTCC/wiki

Home Page: https://www.bytesoft.org/

License: GNU Lesser General Public License v3.0

Java 100.00%

bytetcc's Introduction

ByteTCC是一个基于TCC(Try/Confirm/Cancel)机制的分布式事务管理器。兼容JTA,可以很好的与EJB、Spring等容器(本文档下文说明中将以Spring容器为例)进行集成。

一、快速入门

1.1. 加入maven依赖

1.1.1. 使用Spring Cloud
<dependency>
	<groupId>org.bytesoft</groupId>
	<artifactId>bytetcc-supports-springcloud</artifactId>
	<version>0.4.17</version>
</dependency>
1.1.2. 使用dubbo
<dependency>
	<groupId>org.bytesoft</groupId>
	<artifactId>bytetcc-supports-dubbo</artifactId>
	<version>0.4.17</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特性

  • 1、支持Spring容器的声明式事务管理;
  • 2、支持普通事务、TCC事务、saga事务等事务机制;
  • 3、支持多数据源、跨应用、跨服务器等分布式事务场景;
  • 4、支持长事务;
  • 5、支持dubbo服务框架;
  • 6、支持spring cloud;

四、历史版本

4.1. v0.3.x

4.2. v0.2.0-alpha

4.3. v0.1.2

4.4. v0.1

五、建议及改进

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

bytetcc's People

Contributors

liuyangming avatar xingfudeshi avatar

Watchers

 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.