Skip to content

Commit b005b1a

Browse files
authored
translation: Added Chinese Translation for Commander patterns (#2763)
1 parent fb80886 commit b005b1a

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: Commander
3+
category: Concurrency
4+
language: zh
5+
tag:
6+
- Cloud distributed
7+
---
8+
9+
## 目的
10+
11+
> 用于处理执行分布式事务时可能遇到的所有问题。
12+
13+
## 类图
14+
![alt text](./etc/commander.urm.png "Commander class diagram")
15+
16+
## 适用场合
17+
当我们需要提交两个数据库去完成事务,提交不是原子性且可能因此造成问题时,适合用这个设计模式。
18+
19+
## 解释
20+
处理分布式事务很棘手,但如果我们不仔细处理,可能会带来不想要的后果。假设我们有一个电子商务网站,它有一个支付微服务和一个运输微服务。如果当前运输可用,但支付服务不可用,或者反之,当我们已经收到用户的订单后,我们应该如何处理?我们需要有一个机制来处理这些情况。我们必须将订单指向其中一个服务(在这个例子中是运输),然后将订单添加到另一个服务的数据库中(在这个例子中是支付),因为两个数据库不能原子地更新。如果我们当前无法做到这一点,应该有一个队列,可以将这个请求排队,并且必须有一个机制,允许队列中出现失败。所有这些都需要通过不断的重试,在保证幂等性(即使请求多次,变化只应用一次)的情况下,由一个指挥类来完成,以达到最终一致性的状态。
21+
22+
## 鸣谢
23+
24+
* [Distributed Transactions: The Icebergs of Microservices](https://www.grahamlea.com/2016/08/distributed-transactions-microservices-icebergs/)
315 KB
Loading

0 commit comments

Comments
 (0)