Skip to content

optimize: add support for configuring exposeProxy in GlobalTransactionScanner #6566

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

Merged
merged 11 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#6209](https://github.com/apache/incubator-seata/pull/6209)] Eliminate RpcMessage and Encoder/Decoder dependencies
- [[#6634](https://github.com/apache/incubator-seata/pull/6634)] select channel handles based on protocol versions
- [[#6523](https://github.com/apache/incubator-seata/pull/6523)] upgrade alibaba/druid version to 1.2.20

- [[#6566](https://github.com/apache/incubator-seata/pull/6566)] Add support for configuring exposeProxy in GlobalTransactionScanner
- [[#6534](https://github.com/apache/incubator-seata/pull/6534)] optimize: send async response

### refactor:
- [[#6534](https://github.com/apache/incubator-seata/pull/6534)] optimize: send async response

### security:

Expand All @@ -40,5 +40,6 @@ Thanks to these contributors for their code commits. Please report an unintended
- [Bughue](https://github.com/Bughue)
- [funky-eyes](https://github.com/funky-eyes)
- [tanyaofei](https://github.com/tanyaofei)
- [wanghongzhou](https://github.com/wanghongzhou)

Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.
6 changes: 4 additions & 2 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
- [[#6209](https://github.com/apache/incubator-seata/pull/6209)] 解开 RpcMessage 和 Encoder/Decoder 的互相依赖
- [[#6634](https://github.com/apache/incubator-seata/pull/6634)] 根据协议版本指定channel handle
- [[#6523](https://github.com/apache/incubator-seata/pull/6523)] 升级 alibaba/druid 的版本到1.2.20

- [[#6566](https://github.com/apache/incubator-seata/pull/6566)] 支持GlobalTransactionScanner类中exposeProxy属性的配置
- [[#6534](https://github.com/apache/incubator-seata/pull/6534)] 优化: 发送异步响应

### refactor:
- [[#6534](https://github.com/apache/incubator-seata/pull/6534)] 优化: 发送异步响应


### security:

Expand All @@ -39,6 +40,7 @@
- [Bughue](https://github.com/Bughue)
- [funky-eyes](https://github.com/funky-eyes)
- [tanyaofei](https://github.com/tanyaofei)
- [wanghongzhou](https://github.com/wanghongzhou)


同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ public GlobalTransactionScanner(String applicationId, String txServiceGroup, Fai
super(applicationId, txServiceGroup, failureHandlerHook);
}

/**
* Instantiates a new Global transaction scanner.
*
* @param applicationId the application id
* @param txServiceGroup the tx service group
* @param exposeProxy the exposeProxy
* @param failureHandlerHook the failure handler hook
*/
public GlobalTransactionScanner(String applicationId, String txServiceGroup, boolean exposeProxy, FailureHandler failureHandlerHook) {
super(applicationId, txServiceGroup, exposeProxy, failureHandlerHook);
}

/**
* Instantiates a new Global transaction scanner.
*
Expand All @@ -94,7 +106,20 @@ public GlobalTransactionScanner(String applicationId, String txServiceGroup, Fai
* @param failureHandlerHook the failure handler hook
*/
public GlobalTransactionScanner(String applicationId, String txServiceGroup, int mode, FailureHandler failureHandlerHook) {
super(applicationId, txServiceGroup, mode, failureHandlerHook);
super(applicationId, txServiceGroup, mode, false, failureHandlerHook);
}

/**
* Instantiates a new Global transaction scanner.
*
* @param applicationId the application id
* @param txServiceGroup the tx service group
* @param mode the mode
* @param exposeProxy the exposeProxy
* @param failureHandlerHook the failure handler hook
*/
public GlobalTransactionScanner(String applicationId, String txServiceGroup, int mode, boolean exposeProxy, FailureHandler failureHandlerHook) {
super(applicationId, txServiceGroup, mode, exposeProxy, failureHandlerHook);
}

protected void initClient() {
Expand Down
1 change: 1 addition & 0 deletions script/client/spring/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ seata.secret-key=aliyunSecretKey
seata.enable-auto-data-source-proxy=true
seata.data-source-proxy-mode=AT
seata.use-jdk-proxy=false
seata.expose-proxy=false
seata.client.rm.async-commit-buffer-limit=10000
seata.client.rm.report-retry-count=5
seata.client.rm.table-meta-check-enable=false
Expand Down
1 change: 1 addition & 0 deletions script/client/spring/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ seata:
enable-auto-data-source-proxy: true
data-source-proxy-mode: AT
use-jdk-proxy: false
expose-proxy: false
scan-packages: firstPackage,secondPackage
excludes-for-scanning: firstBeanNameForExclude,secondBeanNameForExclude
excludes-for-auto-proxying: firstClassNameForExclude,secondClassNameForExclude
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public class SeataProperties {
* Whether use JDK proxy instead of CGLIB proxy
*/
private boolean useJdkProxy = false;
/**
* Whether to expose the proxy object through AopContext.
* Setting this to true allows AopContext.currentProxy() to be used to obtain the current proxy,
* which can be useful for invoking methods annotated with @GlobalTransactional within the same class.
*/
private boolean exposeProxy = false;
/**
* The scan packages. If empty, will scan all beans.
*/
Expand Down Expand Up @@ -136,6 +142,14 @@ public SeataProperties setUseJdkProxy(boolean useJdkProxy) {
return this;
}

public boolean isExposeProxy() {
return exposeProxy;
}

public void setExposeProxy(boolean exposeProxy) {
this.exposeProxy = exposeProxy;
}

public String[] getExcludesForAutoProxying() {
return excludesForAutoProxying;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public static GlobalTransactionScanner globalTransactionScanner(SeataProperties
GlobalTransactionScanner.setAccessKey(seataProperties.getAccessKey());
GlobalTransactionScanner.setSecretKey(seataProperties.getSecretKey());
// create global transaction scanner
return new GlobalTransactionScanner(seataProperties.getApplicationId(), seataProperties.getTxServiceGroup(), failureHandler);
return new GlobalTransactionScanner(seataProperties.getApplicationId(), seataProperties.getTxServiceGroup(),
seataProperties.isExposeProxy(), failureHandler);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public GlobalTransactionScanner(String applicationId, String txServiceGroup) {
* @param mode the mode
*/
public GlobalTransactionScanner(String applicationId, String txServiceGroup, int mode) {
this(applicationId, txServiceGroup, mode, null);
this(applicationId, txServiceGroup, mode, false, null);
}

/**
Expand All @@ -171,7 +171,20 @@ public GlobalTransactionScanner(String applicationId, String txServiceGroup, int
* @param failureHandlerHook the failure handler hook
*/
public GlobalTransactionScanner(String applicationId, String txServiceGroup, FailureHandler failureHandlerHook) {
this(applicationId, txServiceGroup, DEFAULT_MODE, failureHandlerHook);
this(applicationId, txServiceGroup, DEFAULT_MODE, false, failureHandlerHook);
}

/**
* Instantiates a new Global transaction scanner.
*
* @param applicationId the application id
* @param txServiceGroup the tx service group
* @param exposeProxy the exposeProxy
* @param failureHandlerHook the failure handler hook
*/
public GlobalTransactionScanner(String applicationId, String txServiceGroup, boolean exposeProxy,
FailureHandler failureHandlerHook) {
this(applicationId, txServiceGroup, DEFAULT_MODE, exposeProxy, failureHandlerHook);
}

/**
Expand All @@ -180,12 +193,14 @@ public GlobalTransactionScanner(String applicationId, String txServiceGroup, Fai
* @param applicationId the application id
* @param txServiceGroup the tx service group
* @param mode the mode
* @param exposeProxy the exposeProxy
* @param failureHandlerHook the failure handler hook
*/
public GlobalTransactionScanner(String applicationId, String txServiceGroup, int mode,
public GlobalTransactionScanner(String applicationId, String txServiceGroup, int mode, boolean exposeProxy,
FailureHandler failureHandlerHook) {
setOrder(ORDER_NUM);
setProxyTargetClass(true);
setExposeProxy(exposeProxy);
this.applicationId = applicationId;
this.txServiceGroup = txServiceGroup;
this.failureHandlerHook = failureHandlerHook;
Expand Down
Loading