Closed Theodore1965 closed 1 month ago
如果出现retry client侧应该有日志,请把你的示例代码和,client侧的日志提交上来 If there should be a log on the client side of the retry, please send your sample code and the log commit on the client side
一个比较简单的方案,如果你是spring的应用
DefaultCommonFenceHandler.get().setFenceHandler(new SpringFenceHandler());
将上面的SpringFenceHandler
包装后,用你的动态数据源处理后,再执行SpringFenceHandler
的逻辑,或者你直接继承SpringFenceHandler
进行处理动态数据源的逻辑
如果你不是spring的应用,你也可以通过这个api,自行扩展一个FenceHandler
,再应用启动时第一时间放入DefaultCommonFenceHandler
中
A straightforward approach, if you are using a Spring application:
DefaultCommonFenceHandler.get().setFenceHandler(new SpringFenceHandler());
After wrapping the SpringFenceHandler
with your dynamic data source handling, proceed to execute the logic of SpringFenceHandler. Alternatively, you can extend SpringFenceHandler
directly to incorporate the dynamic data source logic.
For applications not using Spring, you can also extend this API by independently extending a FenceHandler
and placing it into DefaultCommonFenceHandler
at startup.
一个比较简单的方案,如果你是spring的应用,
DefaultCommonFenceHandler.get().setFenceHandler(new SpringFenceHandler());
将上面的SpringFenceHandler
包装后,用你的动态数据源处理后,再执行SpringFenceHandler
的逻辑,或者你直接继承SpringFenceHandler
进行处理动态数据源的逻辑 如果你不是spring的应用,你也可以通过这个api,自行扩展一个FenceHandler
,再应用启动时第一时间进入DefaultCommonFenceHandler
中如果您使用 Spring 应用程序,那么一个简单的方法:
DefaultCommonFenceHandler.get().setFenceHandler(new SpringFenceHandler());
用动态数据源处理包装后SpringFenceHandler
,继续执行 SpringFenceHandler 的逻辑。或者,您可以SpringFenceHandler
直接扩展以合并动态数据源逻辑。对于不使用 Spring 的应用程序,您还可以通过独立扩展并在启动时
FenceHandler
将其放入来扩展此 API。DefaultCommonFenceHandler
我看到SpringFenceHandler是2.0版本的,我用的是1.7.1,用TCCFenceHandler可以么, 1.7.1版本能否提供个关键代码部分的demo,万分感谢! 项目是Springboot2.7的
1.7.1版本,我是每次都要TCCFenceHandler.setDataSource()和TCCFenceHandler.setTransactionTemplate()么
1.7.1版本,我是每次都要TCCFenceHandler.setDataSource()和TCCFenceHandler.setTransactionTemplate()么 老哥,可以给下复现代码么(prepare、commit、rollback代码)
一个比较简单的方案,如果你是spring的应用,
DefaultCommonFenceHandler.get().setFenceHandler(new SpringFenceHandler());
将上面的SpringFenceHandler
包装后,用你的动态数据源处理后,再执行SpringFenceHandler
的逻辑,或者你直接继承SpringFenceHandler
进行处理动态数据源的逻辑 如果你不是spring的应用,你也可以通过这个api,自行扩展一个FenceHandler
,再应用启动时第一时间进入DefaultCommonFenceHandler
中 如果您使用 Spring 应用程序,那么一个简单的方法:DefaultCommonFenceHandler.get().setFenceHandler(new SpringFenceHandler());
用动态数据源处理包装后SpringFenceHandler
,继续执行 SpringFenceHandler 的逻辑。或者,您可以SpringFenceHandler
直接扩展以合并动态数据源逻辑。 对于不使用 Spring 的应用程序,您还可以通过独立扩展并在启动时FenceHandler
将其放入来扩展此 API。DefaultCommonFenceHandler
我看到SpringFenceHandler是2.0版本的,我用的是1.7.1,用TCCFenceHandler可以么, 1.7.1版本能否提供个关键代码部分的demo,万分感谢! 项目是Springboot2.7的
1.7.1版本,我是每次都要TCCFenceHandler.setDataSource()和TCCFenceHandler.setTransactionTemplate()么
首先你自己创建一个TCCFenceHandler的子类的bean,seata侧就不会再构建TCCFenceHandler的bean,所以注入的是你的TCCFenceHandler,因为TCCFenceHandler是通过spring的DataSourceUtils获取的connection,只要你在这个之前,通过actionname能判断出来这个接口需要哪个数据源,或者通过commitMethod方法上的注解切换这个线程下的动态数据源的主数据源为哪个datasource就可以了,所以不需要每次都进行set之类的。
OK,明白了,感谢
Ⅰ. Issue Description
使用动态数据源,TCC模式下,一直Retry无法提交, 如何不切换数据源,代码是没问题的
Ⅱ. Describe what happened
If there is an exception, please attach the exception trace: