我的TM是这样的:
@GlobalTransactional
@ApiOperation(value = "tcc")
@PostMapping("/tcc")
public void tcc(){
System.out.println(tccProviderService.prepare(null));
System.out.println(tccProviderService2.prepare(null));
throw new RuntimeException("123");
}
RM是这样的,两个都差不多就贴一个:
@DubboService(group = "tcc2")
public class TCCProviderServiceImpl implements TCCProviderService2 {
@Override
public String prepare(BusinessActionContext context) {
System.out.println("准备2");
return "tcc生产者2";
}
@Override
public String commit(BusinessActionContext context) {
System.out.println("提交2");
return "提交2";
}
@Override
public String rollback(BusinessActionContext context) {
System.out.println("回滚2");
return "回滚2";
}
}
然后我的TCC接口是这样的:
public interface TCCProviderService2 {
@TwoPhaseBusinessAction(name = "tt2")
String prepare(BusinessActionContext context);
String commit(BusinessActionContext context);
String rollback(BusinessActionContext context);
}
这个调用prepare方法都成功了,但是不论回滚还是提交,最后的seata服务都会报错:
最后我翻看了下tcc的源码发现二阶段提交TwoPhaseBusinessAction注解上有这么一句话:
* TCC annotation.
* Define a TCC interface, which added on the try method.
* Must be used with `@LocalTCC`.
请问,这是否意味着,我上面的TCC写法是不支持的?我看github上的案例也是要么加了localTCC注解,要么dubbo生产者都在同一个服务里。