explaingit

changmingxie/tcc-transaction

5,771JavaAudience · developerComplexity · 4/5Setup · hard

TLDR

A Java library that coordinates transactions across multiple services using the Try-Confirm-Cancel pattern, so either all steps complete or all are rolled back cleanly, solving the core data consistency problem in microservice architectures.

Mindmap

mindmap
  root((tcc-transaction))
    What it does
      Distributed transactions
      Try Confirm Cancel
      Rollback across services
    Tech Stack
      Java
      Spring Cloud
    Use Cases
      Multi-service checkout
      Database coordination
      Microservice reliability
    Audience
      Java developers
      Backend engineers
    Setup
      Wiki required
      Maven dependency
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Coordinate a payment and inventory update across two separate services so both succeed or both roll back together.

USE CASE 2

Replace ad-hoc error handling in microservice workflows with a reliable, rollback-safe transaction pattern.

USE CASE 3

Add distributed transaction support to a Spring-based microservice application without a full saga framework.

Tech stack

Java

Getting it running

Difficulty · hard Time to first run · 1h+

Repository README is brief and in Chinese, the linked wiki is required reading before setup.

Not specified in the repository documentation.

In plain English

tcc-transaction is a Java library that implements the TCC pattern for handling transactions across multiple separate services or databases. TCC stands for Try, Confirm, and Cancel, which are the three phases a transaction goes through. In the Try phase, the system checks that all the business conditions are met and reserves the required resources without actually completing anything. This is like placing a hold on inventory or funds rather than spending them. In the Confirm phase, the system uses only those pre-reserved resources to complete the actual operation. If something goes wrong and the transaction cannot proceed, the Cancel phase releases whatever was reserved during Try, leaving the system in its original state. This pattern exists to solve a specific problem in distributed systems, where a single business operation touches multiple independent services that each manage their own data. Standard database transactions cannot span multiple services, so without a coordination pattern like TCC, a failure partway through can leave some services updated and others not, creating inconsistent data. TCC allows an application to coordinate these services in a way that either all steps complete or all are rolled back cleanly. The README, written in Chinese, is brief and describes only the three-phase structure. It links to a quick-start guide on the project wiki for setup instructions. The project targets Java developers building distributed or microservice applications who need reliable multi-service transaction coordination. Given the sparse documentation in the repository itself, following the linked wiki would be the first step for anyone looking to use or evaluate this library.

Copy-paste prompts

Prompt 1
I am building a Java microservice app where a checkout must update both an inventory service and a payment service atomically. Show me how to use tcc-transaction to implement the Try, Confirm, and Cancel phases for each service.
Prompt 2
Walk me through adding tcc-transaction to a Spring Boot project: what Maven dependencies do I need, how do I annotate service methods for each TCC phase, and how does the coordinator handle a mid-transaction failure?
Prompt 3
Explain the difference between TCC and two-phase commit for distributed transactions and show a tcc-transaction code example handling a transfer between two accounts in separate databases.
Prompt 4
How do I configure tcc-transaction to store in-progress transaction state in my existing PostgreSQL database?
Open on GitHub → Explain another repo

← changmingxie on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.