wanghongzhou commented on issue #6562:
URL:
https://github.com/apache/incubator-seata/issues/6562#issuecomment-2121786534
> This is the same as when you use spring's `@Transactional` annotation, so
how did you solve the same problem with your `@Transactional`?
Certainly! Here's the English translation of your description and
explanation:
---
After adding the `@EnableAspectJAutoProxy(exposeProxy = true)` annotation, I
can obtain the proxy object for `@Transactional` through
`AopContext.currentProxy()`. By using the proxy object, `@Transactional`
becomes effective. However, this annotation does not work for
`@GlobalTransactional`, because the proxy object for `@GlobalTransactional` is
created by `GlobalTransactionScanner`.
I temporarily constructed a `GlobalTransactionScanner` myself, as shown
below:
```java
@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!
--
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]