Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何避免tcc try阶段业务并发重复调用 #327

Open
changmingxie opened this issue Jun 2, 2021 · 2 comments
Open

如何避免tcc try阶段业务并发重复调用 #327

changmingxie opened this issue Jun 2, 2021 · 2 comments

Comments

@changmingxie
Copy link
Owner

changmingxie commented Jun 2, 2021

可以在 tcc事务发起者方法(try方法)添加一个业务主建,并使用@uniqueidentity 标示,如示例项目tcc-transaction-dubbo-order的PaymentServiceImpl.makePayment方法(如下):
public void makePayment(@uniqueidentity String orderNo) ;

tcc框架将使用@uniqueidentity 注解标示的参数作为tcc的主事务xid,如果tcc事务发起者方法同时执行多次,其tcc的主事务xid都是一样的,这样仅有一个请求的tcc事务保存成功,其他的调用则失败。

@zhanglijun1217
Copy link

感觉try阶段做的事情就是占用资源,是一种检查机制。防止重复调用应该由分支事务来控制,完全交由框架感觉有点粗暴~

@17998384
Copy link

幂等性就应该由业务保证,跟框架没关系

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants