TCC principle
TCC principle
In a nutshell
Try: 尝试执行业务
- 完成所有业务检查(一致性)
- 预留必须业务资源(准隔离性)
- Autonomous Timeout and Cancel
Confirm: 确认执行业务
- 真正执行业务
- 不作任何业务检查
- 只使用 Try 阶段预留的业务资源
- 操作满足幂等性
Cancel: 取消执行业务
- 释放 Try 阶段预留的业务资源
- 操作满足幂等性
1 | public interface TccService<P extends TccRequest<R>, R extends Serializable> { |
Participant
Try: ParticipantLink
1
2
3
4
5
6
7{
"participantLink":
{
"uri":"http://www.example.com/v1/tcc/tx/782973177474060290",
"expires":"2017-10-24T10:20:12Z"
}
}Confirm
1
2
3
4
5
6PUT /v1/tcc/tx/782973177474060290 HTTP/1.1
Host: www.example.com
Accept: application/tcc
HTTP/1.1 204 No Content
HTTP/1.1 404 Not FoundCancel
1
2
3
4
5DELETE /v1/tcc/tx/782973177474060290 HTTP/1.1
Host: www.example.com
Accept: application/tcc
HTTP/1.1 204 No ContentURL
1
2
3^/v1/tcc/bo/{type} POST
^/v1/tcc/bo/{type}/{id} PATCH|PUT|DELETE
^/v1/tcc/tx/{txid} PUT to confirm, DELETE to cancel
Coordinator
Confirm all participants when asked to do so.
Recover after failures during the confirmation phase.
Allow cancellation of all participants when asked to do so.
URL
1
2^/v1/tcc/dtc/confirm PUT to confirm
^/v1/tcc/dtc/cancel DELETE to cancel