I'll present the patterns in reverse order of safety(安全) or reliability(可靠), starting with those with the highest guarantee of data integrity and atomicity under the most general circumstances
从最可靠-》最不可靠
The patterns are also roughly in reverse order of runtime cost (starting with the most expensive)。
从最耗时-》最不耗时
A distributed transaction is one that involves more than one transactional resource. Examples of transactional resources are the connectors for communicating with relational databases and messaging middleware.
分布式系统可能会同时操作多个数据源。 比如,经常情况下,我们会操作 关系型数据库 和 消息中间件
The first three patterns discussed below are based on the XA protocol.
两阶段提交可见: http://blog.csdn.net/dbanote/article/details/8981946
http://blog.csdn.net/a837199685/article/details/40979267
XA protocol.
In Java, from the developer's point of view, the protocol is exposed through a JTA UserTransaction.
基本的想法是尽可能的延迟一个事务中资源操作的提交,这样仅有的失败可能是基础设施出问题(而不是业务处理错误)。依赖于这个模式的系统基本上假定系统基础设施的失败很少会发生,这样他们能为了更高的并发处理量而承担这样的失败风险。如果业务处理服务也同样设计为幂等的,那么在实践中很少犯错。
http://blue2048.iteye.com/blog/2191497
可查询操作 + 定期校对 + 保证消息在事务提交后才发送
适用范围
幂等操作 + 可靠消息
优点
适用范围
典型实现:pikaq https://github.com/knightliao/pikaQ
适用范围
成本
适用范围