apache / incubator-seata

:fire: Seata is an easy-to-use, high-performance, open source distributed transaction solution.
https://seata.apache.org/
Apache License 2.0
25.25k stars 8.77k forks source link

SAGA Loop循环事务补偿入参问题咨询 #6776

Open geniusnoopy opened 1 month ago

geniusnoopy commented 1 month ago

Ⅰ. Issue Description

SAGA Loop循环事务补偿入参问题咨询。

Ⅱ. Describe what happened

使用SAGA Loop循环事务时,当事务发生补偿,循环事务里的单个子事务补偿方法入参无法获取到集合单个元素及集合下标。 试了test用例中的org.apache.seata.saga.engine.db.StateMachineDBTests.testSimpleStateMachineWithLoopCompensate()方法,似乎也无法获取到。 请问需要如何配置才能在Loop子事务补偿时入参获取到集合单个元素信息。

Ⅵ. Environment:

wt-better commented 1 month ago

你所谓的补偿是forward还是compensate,forward的话可以使用$.[element],$.[collection]这种;如果是compensate,目前没有机制透传;

ptyin commented 1 month ago

ProcessContext 获取 DomainConstants.LOOP_COUNTER 这个变量是你想要的吗?

geniusnoopy commented 1 month ago

你所谓的补偿是forward还是compensate,forward的话可以使用$.[element],$.[collection]这种;如果是compensate,目前没有机制透传;

是compensate,感谢解答。另外有个疑问是在LoopTaskHandlerInterceptor的preProcess里有compensate时的原ContextVariable获取的相关代码,请问后续是否能够支持?

geniusnoopy commented 1 month ago

ProcessContext 获取 DomainConstants.LOOP_COUNTER 这个变量是你想要的吗?

你好,循环事务在补偿时context里似乎没有loopcounter这个key。