You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2022/02/23 15:31:40 UTC

[GitHub] [servicecomb-pack] Hakunata commented on issue #733: TCC转账场景(A转B),当B用户不存在抛出异常,补偿通知没有调用cancel,而调用了confirm

Hakunata commented on issue #733:
URL: https://github.com/apache/servicecomb-pack/issues/733#issuecomment-1048906636


   > 
   感谢及时回复~
   
   `
       @Around("execution(@org.apache.servicecomb.pack.omega.transaction.annotations.Participate * *(..)) && @annotation(participate)")
       Object advise(ProceedingJoinPoint joinPoint, Participate participate) throws Throwable {
           Method method = ((MethodSignature)joinPoint.getSignature()).getMethod();
           TransactionContext transactionContext = this.extractTransactionContext(joinPoint.getArgs());
           if (transactionContext != null) {
               this.populateOmegaContext(this.context, transactionContext);
           }
   
           String localTxId = this.context.localTxId();
           String cancelMethod = this.callbackMethodSignature(joinPoint, participate.cancelMethod(), method);
           String confirmMethod = this.callbackMethodSignature(joinPoint, participate.confirmMethod(), method);
           this.context.newLocalTxId();
           LOG.debug("Updated context {} for participate method {} ", this.context, method.toString());
   
           Object var10;
           try {
               AlphaResponse response = this.tccMessageSender.participationStart(new ParticipationStartedEvent(this.context.globalTxId(), this.context.localTxId(), localTxId, confirmMethod, cancelMethod));
               if (response.aborted()) {
                   throw new OmegaException("transcation has aborted: " + this.context.globalTxId());
               }
   
               Object result = joinPoint.proceed();
               this.tccMessageSender.participationEnd(new ParticipationEndedEvent(this.context.globalTxId(), this.context.localTxId(), localTxId, confirmMethod, cancelMethod, TransactionStatus.Succeed));
               this.parametersContext.putParameters(this.context.localTxId(), joinPoint.getArgs());
               LOG.debug("Participate Transaction with context {} has finished.", this.context);
               var10 = result;
           } catch (Throwable var14) {
               if (!(var14 instanceof OmegaException)) {
                  // **********************************************
                  // DEBUG断点到这里,异常是捕获到了的
                  // **********************************************
                   this.tccMessageSender.participationEnd(new ParticipationEndedEvent(this.context.globalTxId(), this.context.localTxId(), localTxId, confirmMethod, cancelMethod, TransactionStatus.Failed));
               }
   
               LOG.error("Participate Transaction with context {} failed.", this.context, var14);
               throw var14;
           } finally {
               this.context.setLocalTxId(localTxId);
           }
   
           return var10;
       }`
   
   进入TccParticipatorAspect 类打断点,看到是捕获到异常了。目前POC ServiceComb-Pack,帮忙看看,目前没来得及读完框架代码


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org