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


   > 你可以debug一下Alpha的代码, Alpha 调用Omega agent confirm 或者 cancel的代码在 
org.apache.servicecomb.pack.alpha.server.tcc.callback.GrpcOmegaTccCallback 的 
invoke 方法里面。 里面会比较Transaction的状态, 我估计可能是Transaction的状态出了问题。
   
   发现问题了(A:转出服务;B:转入服务):
   因为父事物里面我catch了B服务的异常,没有在父事物的方法(@TccStart修饰的业务方法)里面再抛出,结果父事物的事物类型是Success
   `@TccStart
       public Result transfer(TransferEntity transferEntity){
           String errMsg = "";
           Integer errCode = 0;
           try{
               ResponseEntity<UserAccount> outResp = 
alphaClient.getForEntity(getBankAlphaURL(transferEntity),UserAccount.class,transferEntity.getFromId(),transferEntity.getMoney()
 );
               System.out.println(outResp.getBody().toString());
               ResponseEntity<UserAccount> inResp = 
betaClient.getForEntity(getBankBetaURL(transferEntity),UserAccount.class,transferEntity.getToId(),transferEntity.getMoney()
 );
               System.out.println(inResp.getBody().toString());
               errMsg = "user[id:"+transferEntity.getFromId()+"] transfer 
meney("+transferEntity.getMoney()+") to user[id:"+transferEntity.getToId()+"] 
success";
           }catch (Exception e){
               e.printStackTrace();
               errMsg = e.getMessage();
               errCode = -1;
               // ***********************************************
               // 这里要继续抛出去,或者确认子事物会throw失败异常,父事物就不应该try...catch
               // ***********************************************
               throw e;
           }
           return new Result(errCode,errMsg);
       }`


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to