apache / incubator-seata-samples

Apache Seata(incubating) Samples for Java
https://seata.apache.org/
Apache License 2.0
2.27k stars 1.92k forks source link

tcc BusinessActionContext get null #86

Open ShootMooN opened 5 years ago

ShootMooN commented 5 years ago

Try to write a springboot dubbo tcc demo base on the dubbo-tcc-sample. When I run my code, the parameter 'BusinessActionContext actionContext' of method 'prepare' shows null. Have tried everything I can, but still can not solve this problem.

yourchanges commented 5 years ago

same problem

xiexiaobiao commented 5 years ago

I have meet the same problem! dubbo2.7.3 + seata0.8.1+springBoot2.1.9, no solution found yet. someone said use the spring and XML to inject the Dubbo bean will works.

mkyuangithub commented 4 years ago

Hi Please check my correction: first->import io.seata.core.context.RootContext; final String xid = RootContext.getXID(); in each u wanna use the xid like this one, pls use my style: logger.info(String.format("======>prepareMinus account[%s] amount[%f], dtx transaction id: %s.", accountNo, amount, xid));

And...how about the businessActionContext? Seems...the sample writer only use the null value, I also correctted the sample as following codes and for your reference:

public boolean transfer(long from, long to, double amount) throws DemoRpcRunTimeException { BusinessActionContext businessActionContext = new BusinessActionContext(); Map<String, Object> actionContext = new HashMap(); actionContext.put("accountNo", from); actionContext.put("amount", amount); businessActionContext.setActionContext(actionContext);

lavenJHT commented 3 years ago

一样的问题,而且这个seata-sample的demo好Low啊,都是xml的配置,很不利于学习,而且demo中的BusinessActionContext都是null,我想知道提交的作者脑子里在想什么?而且这个玩意官方就没有demo吗?

lavenJHT commented 3 years ago

Hi Please check my correction: first->import io.seata.core.context.RootContext; final String xid = RootContext.getXID(); in each u wanna use the xid like this one, pls use my style: logger.info(String.format("======>prepareMinus account[%s] amount[%f], dtx transaction id: %s.", accountNo, amount, xid));

And...how about the businessActionContext? Seems...the sample writer only use the null value, I also correctted the sample as following codes and for your reference:

public boolean transfer(long from, long to, double amount) throws DemoRpcRunTimeException { BusinessActionContext businessActionContext = new BusinessActionContext(); Map<String, Object> actionContext = new HashMap(); actionContext.put("accountNo", from); actionContext.put("amount", amount); businessActionContext.setActionContext(actionContext);

allready try id,no use

wandun commented 2 years ago

一样的问题,而且这个seata-sample的demo好Low啊,都是xml的配置,很不利于学习,而且demo中的BusinessActionContext都是null,我想知道提交的作者脑子里在想什么?而且这个玩意官方就没有demo吗?

我也是这个问题,但是当我加上适用于SpringCloud+Feign模式下的TCC的注解@LocalTCC 的时候,就可以获取,而且那个demo中是使用的dubbo,并没有使用这个为SpringCloud+Feign模式,也没有加上这个注解,也许是版本的问题?