gene1101 commented on issue #589: servicecomb的向前恢复和逆向补偿不可兼得吗?
URL: 
https://github.com/apache/servicecomb-pack/issues/589#issuecomment-552334071
 
 
   > > > 抱歉,我对 Kyro 
序列化的细节不是太了解,但是我记得序列化只用于在Omega和Alpha之间传递框架内固定的几个事件对象,你能提供进一步细节吗
   > > 
   > > 
   > > 
我看了服务框架,kyro用于将加了补偿注解的方法的参数序列化,然后作为事件的payload发送到alpha,最后持久化到db,然后补偿的时候,通过grpc,把事件转换的命令推回给omega端(之前上报的payload作为输入),此时,omega会序列化推回的payload,转换为补偿方法调用的入参,这也是你们为什么要求补偿方法和标识的业务逻辑方法函数签名一样的原因,如果这些函数签名的入参对象,如果是没有无参构造器的话,kyro是无法反序列化的,
 会导致无法执行补偿命令。
   > > 
![image](https://user-images.githubusercontent.com/15373196/68567976-486d9200-0495-11ea-8a35-79c5133e5af6.png)
   > 
   > 
明白了,你可以在补偿方法里通过omegaContext.globalTxId()和omegaContext.localTxId()可得到当前分布式事务的全局事务ID及本地事务ID,根据这个ID在去获取你补偿需要的参数,这可能需要业务系统做一些工作。
   
   其实我是想表达,你们的readme里要补充一下,
   
![image](https://user-images.githubusercontent.com/15373196/68570721-465b0180-049c-11ea-9e98-5430c4a6bad9.png)
  这些方法参数需要是有无参构造器的类。这是你们框架选择了kyro作为序列化库带来的潜规则了。
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to