-
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
@GlobalTransactional Annotation Not Working Due to Proxy Configuration #6562
Comments
This is the same as when you use spring's |
After adding the I temporarily constructed a @Bean
@ConditionalOnMissingBean
@DependsOn({BEAN_NAME_SPRING_APPLICATION_CONTEXT_PROVIDER, BEAN_NAME_FAILURE_HANDLER})
public GlobalTransactionScanner globalTransactionScanner(SeataProperties seataProperties, FailureHandler failureHandler, ConfigurableListableBeanFactory beanFactory, @Autowired(required = false) List<ScannerChecker> scannerCheckers) {
GlobalTransactionScanner.setBeanFactory(beanFactory);
GlobalTransactionScanner.addScannerCheckers(EnhancedServiceLoader.loadAll(ScannerChecker.class));
GlobalTransactionScanner.addScannerCheckers(scannerCheckers);
GlobalTransactionScanner.addScannablePackages(seataProperties.getScanPackages());
GlobalTransactionScanner.addScannerExcludeBeanNames(seataProperties.getExcludesForScanning());
GlobalTransactionScanner.setAccessKey(seataProperties.getAccessKey());
GlobalTransactionScanner.setSecretKey(seataProperties.getSecretKey());
GlobalTransactionScanner globalTransactionScanner = new GlobalTransactionScanner(seataProperties.getApplicationId(), seataProperties.getTxServiceGroup(), failureHandler);
globalTransactionScanner.setExposeProxy(true);
return globalTransactionScanner;
} Feel free to let me know if you need any further adjustments or additional details! |
Although this might be a question, it seems to stem from a lack of understanding about dynamic proxies. I don't think anyone would really use |
Since you've identified this issue, I believe it's worth submitting a PR to resolve it. |
I believe the code changes required for this PR are minimal. We can add a new property Unfortunately, I'm not very familiar with the PR process. Could you please check if there are other contributors who could help with creating this PR? Thank you! |
我一向认为发现问题的人如果有能力解决该问题的话,我会鼓励和指导他去完成一个pr的提交,这是参与社区的一种体现。 I've always believed that if the person who identifies a problem has the ability to solve it, I would encourage and guide them to submit a PR, which is a manifestation of participating in the community. You can first fork the seata repository, then create a new branch based on the 2.x branch in your forked repository, then pull the branch of your forked repository to local, and carry out code modification and development. When finished, you can commit to the branch of your forked repository, then go back to the seata repository, click on pull requests, then choose new pull requests, select the corresponding branch of your forked repository, and submit to the 2.x branch of the seata repository. https://github.com/apache/incubator-seata/blob/2.x/CONTRIBUTING.md |
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:
Class Setup:
A
andB
.A
calls methodB
.A
does not have any annotations.B
is annotated with@GlobalTransactional
.Observation:
@GlobalTransactional
annotation on methodB
is not triggering the global transaction.A
toB
bypasses the proxy object, thereby skipping the transactional proxy.Attempted Solution:
AopContext.currentProxy()
to get the proxy object within methodA
.Error Encountered:
AopContext.currentProxy()
resulted in an error.Debugging Details:
GlobalTransactionScanner
inherits theexposeProxy
attribute fromProxyConfig
.exposeProxy
attribute defaults tofalse
.CglibAopProxy
class, theAopContext.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 theAopContext.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.
The text was updated successfully, but these errors were encountered: