You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "linghengqian (via GitHub)" <gi...@apache.org> on 2024/02/16 14:16:28 UTC

Re: [I] SpringCloud+Seata1.5.2+ShardingSphereJDBC5.2.1 SeataATShardingSphereTransactionManager.commit throw null exception [shardingsphere]

linghengqian commented on issue #22356:
URL: https://github.com/apache/shardingsphere/issues/22356#issuecomment-1948463141

   @huangxiuqi
   - I was interested in taking a look at the current issue while orchestrating #30146 , but `org.apache.shardingsphere.transaction.annotation.ShardingSphereTransactionType` has been removed with the removal of Spring Boot Starter in #23724 .
   - I'm wondering what happens if you just use Jakarta EE 8's `javax.transaction.Transactional` annotation or Jakarta EE 9+'s `jakarta.transaction.Transactional` annotation? 
   - Please note that according to Seata side requirements, **you should not use the `io.seata.spring.annotation.GlobalTransactional` annotation on ShardingSphere data sources**. Refer to https://github.com/apache/incubator-seata-samples/tree/master/springcloud-seata-sharding-jdbc-mybatis-plus-samples for an explanation of this.
   
   > 但是这里要注意一个问题!!!!!!
   > 虽然SeataATShardingTransactionManager和GlobalTransactionScanner做的事情一样,但是二者绝对不能混合使用!!!!!!
   > 也就是说@ShardingTransactionType(TransactionType.BASE)和@GlobalTransactional绝对不能同时出现!!!!!!
   > 看过上面SeataATShardingTransactionManager你就能明白,ShardingSphere把获取到的全局事务,放到了线程的局部变量里面了。而GlobalTransactionScanner则是采用动态代理的方式对方法进行增强。根本不能放在一起,杂交是要出问题的!
   > ok!最终总结一句!
   > 只要你的项目中用到sharding-jdbc,那么你全部微服务都需要导入seata整合sharding-jdbc的jar包
   > 而且,你的项目中千万不能再出现@GlobalTransactional注解了,用SeataATShardingTransactionManager就可以了。
   
   - From Seata's explanation, I can only think that you should not use `io.seata:seata-spring-boot-starter`. I personally tend to think that the current issue is essentially a documentation issue.


-- 
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-unsubscribe@shardingsphere.apache.org

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