wanghongzhou opened a new issue, #6562:
URL: https://github.com/apache/incubator-seata/issues/6562
### Issue Title: Bug Report - `@GlobalTransactional` Annotation Not Working
Due to Proxy Configuration
### Issue Description:
**Problem Summary:**
I encountered an issue where the `@GlobalTransactional` annotation is not
effective when a method in the same class calls another method annotated with
`@GlobalTransactional`. The global transaction is not initiated in such cases.
Below are the detailed steps and observations:
**Steps to Reproduce:**
1. **Class Setup:**
- I have a Service class with two methods, `A` and `B`.
- Method `A` calls method `B`.
- Method `A` does not have any annotations.
- Method `B` is annotated with `@GlobalTransactional`.
2. **Observation:**
- The `@GlobalTransactional` annotation on method `B` is not triggering
the global transaction.
- This behavior is due to the fact that the call from method `A` to `B`
bypasses the proxy object, thereby skipping the transactional proxy.
3. **Attempted Solution:**
- I attempted to use `AopContext.currentProxy()` to get the proxy object
within method `A`.
4. **Error Encountered:**
- Using `AopContext.currentProxy()` resulted in an error.
**Debugging Details:**
- Upon debugging, I discovered that the `GlobalTransactionScanner` inherits
the `exposeProxy` attribute from `ProxyConfig`.
- The `exposeProxy` attribute defaults to `false`.
- Consequently, in the `CglibAopProxy` class, the
`AopContext.setCurrentProxy(proxy)` method is not executed, leading to the
aforementioned issue.
**Request:**
Could you provide support for directly configuring the `exposeProxy`
attribute? This would allow the `AopContext.setCurrentProxy(proxy)` method to
be executed, thereby enabling the `@GlobalTransactional` annotation to function
correctly in cases where a method within the same class calls another annotated
method.
**Additional Context:**
Ensuring that the `exposeProxy` attribute can be configured would greatly
enhance the usability of the `@GlobalTransactional` annotation, especially in
complex service classes where internal method calls are common.
Thank you for your attention to this matter. I look forward to your response
and a potential fix or workaround for this 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]