Repository navigation
Replies: 1 comment
|
The async default isn't the root cause. The problem is Spring AOP self-invocation inside the generated Every call after the first is The usual fix, which doesn't require overriding the async method: keep the Dubbo impl thin and put the transactional work in a separate bean: @DubboService
public class GreeterImpl extends DubboGreeterTriple.GreeterImplBase {
private final GreeterTxService txService;
public GreeterImpl(GreeterTxService txService) { this.txService = txService; }
@Override
public HelloReply sayHello(HelloRequest request) {
return txService.sayHello(request); // call goes through the Spring proxy
}
}
@Service
public class GreeterTxService {
@Transactional
public HelloReply sayHello(HelloRequest request) { /* DB work */ }
}Other options: If this solves it, please mark it as the answer so others with the same problem can find it. |
Uh oh!
There was an error while loading. Please reload this page.
Pre-check
Apache Dubbo Component
Java SDK (apache/dubbo)
Details
The method invocation defaults to the asynchronous implementation, causing Spring @transactional to not take effect. I would prefer not to override the async method. Are there any better solutions to address this issue?
Code of Conduct
All reactions