[ 
https://issues.apache.org/jira/browse/SCB-212?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16321655#comment-16321655
 ] 

ASF GitHub Bot commented on SCB-212:
------------------------------------

eric-lee-ltk commented on a change in pull request #112: [SCB-212] tx timeout
URL: 
https://github.com/apache/incubator-servicecomb-saga/pull/112#discussion_r160858794
 
 

 ##########
 File path: 
omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessor.java
 ##########
 @@ -19,25 +19,40 @@
 
 import org.apache.servicecomb.saga.omega.context.OmegaContext;
 
-public class SagaStartAnnotationProcessor {
+class SagaStartAnnotationProcessor implements EventAwareInterceptor {
 
   private final OmegaContext omegaContext;
-
   private final MessageSender sender;
 
   SagaStartAnnotationProcessor(OmegaContext omegaContext, MessageSender 
sender) {
     this.omegaContext = omegaContext;
     this.sender = sender;
   }
 
-  void preIntercept() {
-    String globalTxId = omegaContext.newGlobalTxId();
+  @Override
+  public void preIntercept(String parentTxId, String compensationMethod, 
Object... message) {
+    String globalTxId = globalTxId();
     // reuse the globalTxId as localTxId to differ localTxId in 
SagaStartedEvent and the first TxStartedEvent
     sender.send(new SagaStartedEvent(globalTxId, globalTxId));
   }
 
-  void postIntercept() {
+  @Override
+  public void postIntercept(String parentTxId, String compensationMethod) {
     String globalTxId = omegaContext.globalTxId();
     sender.send(new SagaEndedEvent(globalTxId, globalTxId));
+    omegaContext.clear();
+  }
+
+  @Override
+  public void onError(String parentTxId, String compensationMethod, Throwable 
throwable) {
+    String globalTxId = omegaContext.globalTxId();
+    sender.send(new TxAbortedEvent(globalTxId, globalTxId, null, 
compensationMethod, throwable));
+    omegaContext.clear();
+  }
+
+  private String globalTxId() {
 
 Review comment:
   maybe rename to initOmegaContext is easier to understand the intention?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> [pack] sub-transaction timeout support
> --------------------------------------
>
>                 Key: SCB-212
>                 URL: https://issues.apache.org/jira/browse/SCB-212
>             Project: Apache ServiceComb
>          Issue Type: New Feature
>          Components: Saga
>            Reporter: Yin Xiang
>            Assignee: Yin Xiang
>
>  as a dev, i want to set timeout on my sub-transaction, so that i can cancel 
> or retry to make sure the global tx states across services are consistent



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to