wxrqforever commented on issue #7047:
URL: 
https://github.com/apache/incubator-seata/issues/7047#issuecomment-2568952865

   > 这个问题我认为有2个原因
   > 
1.parseAnnotation中应该对方法不存在进行跳过,不应该直接抛异常,因为其中可能存在代理类,并且其中还存在第二个问题,当实现类与接口并存tcc注解时,会出现问题,所以这里的逻辑我认为最好改为子类优先,父类注解的值应该被子类替换(这也是官网里为什么建议大家放到实现类中,而不是接口上的原因),以及这个遍历实际上只需要运行一次,只要initCommonFenceCleanTask执行完成后,就不应该再次进行,即`businessAction.useTCCFence()`
 为true时,外层的for也是没意义的,而且会影响启动应用的耗时
   > 2.GlobalTransactionScanner的优先级低于aop,导致aop先行代理后,得到了一个代理bean,而不是真正的targetbean
   > 我认为修复该问题,可以从第一点下手,也是你所提到的问题,你可以提交一个pr来帮助社区修复该问题吗?
   
   没问题的哥,我理解就是对parseAnnotation进行优化,去掉非必要的循环也无须抛出异常。
   
   
但是我还有个疑问,针对提出的原因1,官网建议的是将@LocalTcc和@TwoPhaseBusinessAction的两个注解放到实现类中吗?这个我也尝试过,我发现如果将这两个注解都放到实现类中的话,目前代码(seata-2.1)是无法识别@
 
TwoPhaseBusinessAction这个注解,这会导致目标业务对象不会被TccActionInterceptorHandler代理,最终导致tcc实际不会生效,这在我提交的demo也可以复现,原因也是因为代理类导致的。这样的话即使我对parseAnnotation进行了优化,也无法解决上面的问题。
   
   导致不生效的代码,我定位认为是在这里:
   
org.apache.seata.rm.tcc.interceptor.parser.TccActionInterceptorParser#tccProxyTargetMethod
   <img width="1208" alt="image" 
src="https://github.com/user-attachments/assets/58e242d9-c8f6-4c97-af73-b3851415bee5";
 />
   
这里代码里拿到的method实际是aop代理对象的,这时候的method已丢失注解信息,导致了误判。这里我个人认为是还需要获取原对象method信息,才能够同时兼容@LocalTcc和@TwoPhaseBusinessAction放在实现类上的场景。
   
   


-- 
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: notifications-unsubscr...@seata.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org
For additional commands, e-mail: notifications-h...@seata.apache.org

Reply via email to