You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2019/07/24 06:12:36 UTC
[servicecomb-pack] 03/05: SCB-1389 Polish doc with suggestion of
Feng Zheng
This is an automated email from the ASF dual-hosted git repository.
ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-pack.git
commit f74333a7eae47ebafecf8cc3eba5116858fe4359
Author: Daniel Qian <ch...@gmail.com>
AuthorDate: Tue Jul 23 15:24:15 2019 +0800
SCB-1389 Polish doc with suggestion of Feng Zheng
---
docs/user_guide.md | 18 +++++++++---------
docs/user_guide_zh.md | 18 +++++++++---------
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/docs/user_guide.md b/docs/user_guide.md
index c434121..92d9d49 100644
--- a/docs/user_guide.md
+++ b/docs/user_guide.md
@@ -155,25 +155,25 @@ Service A:
```java
@SagaStart
public void foo(BarCommand cmd) {
- TransactionContext txContext = omegaContext.getTransactionContext();
- someRpc.send(cmd, txContext);
+ TransactionContext localTxContext = omegaContext.getTransactionContext();
+ someRpc.send(cmd, localTxContext);
}
```
Service B:
```java
-public void listen(BarCommand cmd, TransactionContext parentTxContext) {
- bar(cmd, txContext);
+public void listen(BarCommand cmd, TransactionContext injectedTxContext) {
+ bar(cmd, injectedTxContext);
}
@Compensable
-public void bar(BarCommand cmd, TransactionContext parentTxContext) {
+public void bar(BarCommand cmd, TransactionContext injectedTxContext) {
...
- // TransactionContext childTxContext = omegaContext.getTransactionContext();
+ // TransactionContext localTxContext = omegaContext.getTransactionContext();
}
```
-Notice that `bar` method got parent transaction context in parameter list, and got child transaction context from `OmegaContext` in method body. So if you want to passing transaction context to another service, you should pass child transaction context.
+Notice that `bar` method got an injected transaction context in parameter list, and got a local transaction context from `OmegaContext`. If service B needs to explictly pass transaction context to another service, local transaction context should be used.
##### TransactionContextProperties
@@ -205,11 +205,11 @@ public void listen(BarCommandWithTxContext cmdWithTxContext) {
@Compensable
public void bar(BarCommandWithTxContext cmdWithTxContext) {
...
- // TransactionContext childTxContext = omegaContext.getTransactionContext();
+ // TransactionContext localTxContext = omegaContext.getTransactionContext();
}
```
-Similar to the previous approach, `cmdWithTxContext.get{Global,Local}TxId()` also returns parent transaction context information.
+Similar to the previous approach, `cmdWithTxContext.get{Global,Local}TxId()` also returns injected transaction context information.
### TCC support
diff --git a/docs/user_guide_zh.md b/docs/user_guide_zh.md
index 3997f3a..a12caf4 100644
--- a/docs/user_guide_zh.md
+++ b/docs/user_guide_zh.md
@@ -155,25 +155,25 @@ Service A:
```java
@SagaStart
public void foo(BarCommand cmd) {
- TransactionContext txContext = omegaContext.getTransactionContext();
- someRpc.send(cmd, txContext);
+ TransactionContext localTxContext = omegaContext.getTransactionContext();
+ someRpc.send(cmd, localTxContext);
}
```
Service B:
```java
-public void listen(BarCommand cmd, TransactionContext parentTxContext) {
- bar(cmd, txContext);
+public void listen(BarCommand cmd, TransactionContext injectedTxContext) {
+ bar(cmd, injectedTxContext);
}
@Compensable
-public void bar(BarCommand cmd, TransactionContext parentTxContext) {
+public void bar(BarCommand cmd, TransactionContext injectedTxContext) {
...
- // TransactionContext childTxContext = omegaContext.getTransactionContext();
+ // TransactionContext localTxContext = omegaContext.getTransactionContext();
}
```
-需要注意的是`bar`方法接收到的是父事务上下文,在进入`bar`之后从OmegaContext得到的是子事务上下文(Omega替你开启了新的事务)。如果你需要将事务上下文传递给另一个服务,那么你应该传递子事务上下文。
+需要注意的是`bar`方法接收到的是注入的事务上下文,在进入`bar`之后从OmegaContext得到的是本地事务上下文(Omega替你开启了新的事务)。如果Service B也需要显式地传递事务上下文,那么应该使用本地事务上下文。
##### 利用TransactionContextProperties传递
@@ -205,11 +205,11 @@ public void listen(BarCommandWithTxContext cmdWithTxContext) {
@Compensable
public void bar(BarCommandWithTxContext cmdWithTxContext) {
...
- // TransactionContext childTxContext = omegaContext.getTransactionContext();
+ // TransactionContext localTxContext = omegaContext.getTransactionContext();
}
```
-和前面一种方式类似,TransactionContextProperties.get{Global,Local}TxId()返回的也是父事务上下文信息。
+和前面一种方式类似,TransactionContextProperties.get{Global,Local}TxId()返回的也是注入的事务上下文信息。
### TCC 支持
在对应的方法中添加TccStart 和 Participate标注