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


The following commit(s) were added to refs/heads/master by this push:
     new f845ec1  SCB-1425 Docs for @SagaEnd annotation
f845ec1 is described below

commit f845ec1e8d64d4273fadb37aa04e8e52036665ba
Author: Daniel Qian <[email protected]>
AuthorDate: Fri Aug 23 09:31:22 2019 +0800

    SCB-1425 Docs for @SagaEnd annotation
---
 docs/user_guide.md    | 24 ++++++++++++++++++++++++
 docs/user_guide_zh.md | 24 ++++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/docs/user_guide.md b/docs/user_guide.md
index 791b08a..34150f0 100644
--- a/docs/user_guide.md
+++ b/docs/user_guide.md
@@ -211,6 +211,30 @@ public void bar(BarCommandWithTxContext cmdWithTxContext) {
 
 Similar to the previous approach, `cmdWithTxContext.get{Global,Local}TxId()` 
also returns injected transaction context information.
 
+#### End a Saga manually
+
+Since pack-0.5.0 an attribute name `autoClose` is added to `@SagaStart` 
annotation, this attribute is used to control whether a SagaEndedEvent should 
be sent to Alpha after `SagaStart` annotated method is executed (default value 
is `true`). When `autoClose=false` you should use `@SagaEnd` to send 
SagaEndedEvent manually, for example:
+
+Service A:
+
+```java
+@SagaStart(autoClose=false)
+public void foo() {
+  restTemplate.postForEntity("http://service-b/bar";, ...);
+}
+```
+
+Service B:
+
+```java
+@GetMapping("/bar")
+@Compensable
+@SagaEnd
+public void bar() {
+  ...
+}
+```
+
 ### TCC support
 
 Add TCC annotations and corresponding confirm and cancel methods
diff --git a/docs/user_guide_zh.md b/docs/user_guide_zh.md
index a93c692..91ccf52 100644
--- a/docs/user_guide_zh.md
+++ b/docs/user_guide_zh.md
@@ -211,6 +211,30 @@ public void bar(BarCommandWithTxContext cmdWithTxContext) {
 
 和前面一种方式类似,TransactionContextProperties.get{Global,Local}TxId()返回的也是注入的事务上下文信息。
 
+#### 手动结束Saga
+
+从pack-0.5.0开始`@SagaStart`添加了一个属性`autoClose`,该属性用于控制`@SagaStart`所标记的方法执行后是否自动发送SagaEndedEvent(默认值为`true`)。当`autoClose=false`时你需要使用`@SagaEnd`来手动发送`SagaEndedEvent`,比如:
+
+Service A:
+
+```java
+@SagaStart(autoClose=false)
+public void foo() {
+  restTemplate.postForEntity("http://service-b/bar";, ...);
+}
+```
+
+Service B:
+
+```java
+@GetMapping("/bar")
+@Compensable
+@SagaEnd
+public void bar() {
+  ...
+}
+```
+
 ### TCC 支持
 在对应的方法中添加TccStart 和 Participate标注 
  以一个转账应用为例:

Reply via email to