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

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

seanyinx commented on a change in pull request #92: SCB-140 compensated only 
distinct events
URL: 
https://github.com/apache/incubator-servicecomb-saga/pull/92#discussion_r158903430
 
 

 ##########
 File path: 
omega/omega-context/src/main/java/io/servicecomb/saga/omega/context/OmegaContext.java
 ##########
 @@ -73,26 +78,27 @@ public void setParentTxId(String parentTxId) {
   }
 
   // TODO: 2017/12/23 remove this context entry by the end of its 
corresponding global tx
-  public void addContext(String id, Object target, String compensationMethod, 
Object... args) {
-    compensationContexts.put(id, new CompensationContext(target, 
compensationMethod, args));
+  public void addContext(String globalTxId, String localTxId, Object target, 
String compensationMethod, Object... args) {
+    compensationContexts.computeIfAbsent(globalTxId, k -> new 
ConcurrentHashMap<>())
+        .put(localTxId, new CompensationContext(target, compensationMethod, 
args));
   }
 
   public boolean containsContext(String globalTxId) {
     return compensationContexts.containsKey(globalTxId);
   }
 
   public void compensate(String globalTxId) {
-    CompensationContext compensationContext = 
compensationContexts.get(globalTxId);
-
-    try {
-      invokeMethod(compensationContext);
-    } catch (NoSuchMethodException | IllegalAccessException | 
InvocationTargetException e) {
-      throw new IllegalStateException(
-          "Pre-checking for compensate method " + 
compensationContext.compensationMethod
-              + " was somehow skipped, did you forget to configure compensable 
method checking on service startup?",
-          e);
-    } finally {
-      compensationContexts.remove(globalTxId);
+    Map<String, CompensationContext> contexts = 
compensationContexts.remove(globalTxId);
 
 Review comment:
   not really, it's sent to alpha. we just didn't wire it up yet. that part is 
to be done, after callback is implemented.

----------------------------------------------------------------
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:
us...@infra.apache.org


> [pack] do not compensate duplicate transaction events
> -----------------------------------------------------
>
>                 Key: SCB-140
>                 URL: https://issues.apache.org/jira/browse/SCB-140
>             Project: Apache ServiceComb
>          Issue Type: Improvement
>          Components: Saga
>            Reporter: Yin Xiang
>            Assignee: Yin Xiang
>
> as a dev, i may have duplicate tx events sent to alpha on retry, but i don't 
> want to compensate them more than once, so that my service doesn't spend 
> extra cpu cycles   on meaningless work.



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

Reply via email to