-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
feature : SAGA annotation mode #4577
Changes from 1 commit
aa9f275
ff77aea
6370d38
7f05fbf
a9fe9d7
f6f1b9e
3b116b5
444e478
a675613
3fe3f82
bcf3aaa
bd6a2c0
475ebdb
7e173a3
b6c271e
f2e32d3
9af0ee1
7d30bdb
114737b
4e06ffc
5b0a5b3
dfffdc8
6b8e7f9
feb5238
1898049
71e1d13
82e0216
ccc0e44
c580b63
b2ef990
88a770e
3af72e0
100fbe5
7bb7f8e
1dafb3a
9d1ae03
aa08f63
97add4a
06de501
ac489eb
4ab2487
cec9e46
533280f
72c102e
779a34c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
import io.seata.core.model.Resource; | ||
import io.seata.rm.AbstractResourceManager; | ||
import io.seata.rm.tcc.api.BusinessActionContext; | ||
import io.seata.rm.tcc.api.ModeType; | ||
|
||
/** | ||
* TCC resource manager | ||
|
@@ -97,6 +98,14 @@ public BranchStatus branchCommit(BranchType branchType, String xid, long branchI | |
//BusinessActionContext | ||
BusinessActionContext businessActionContext = getBusinessActionContext(xid, branchId, resourceId, | ||
applicationData); | ||
|
||
// if the TwoPhaseBusinessAction annotation's mode is SAGA, cancel the commit | ||
ModeType modeType = (ModeType) businessActionContext.getActionContext(Constants.MODE_TYPE); | ||
if(modeType != null && modeType.equals( ModeType.SAGA)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 代码格式化一下 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 如果spring cloud用户使用注解式SAGA的话,需要打上@LocalTCC的注解,对于用户来说这个其实比较困惑 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 您好,已经格式提交。 |
||
LOGGER.info("TwoPhaseBusinessAction's ModeType is SAGA, cancel the commit, xid: {}, branchId: {}, resourceId: {}", xid, branchId, resourceId); | ||
return BranchStatus.PhaseTwo_Committed; | ||
} | ||
|
||
Object[] args = this.getTwoPhaseCommitArgs(tccResource, businessActionContext); | ||
Object ret; | ||
boolean result; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.seata.rm.tcc.api; | ||
|
||
/** | ||
* The enum ModeType | ||
* | ||
* @author ruishan | ||
*/ | ||
public enum ModeType { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不要使用新类,直接使用BranchType 枚举类 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已经去掉ModeType,改成BranchType |
||
|
||
/** | ||
* TCC Mode | ||
*/ | ||
TCC, | ||
/** | ||
* SAGA Mode | ||
*/ | ||
SAGA; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DefaultCore#doGlobalCommit 直接处理即可
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我再看一下这里DefaultCore#doGlobalCommit ,如果结合新的注解Compensable来处理
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
确实要改成SAGA的branchtype,所以对于ActionInterceptorHandler来处理SAGA,我想可能新增一个doSagaActionLogStore来处理,或者考虑可重用来在内部兼容处理SAGA的branchtype注册至tc