[ 
https://issues.apache.org/jira/browse/SCB-785?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16561144#comment-16561144
 ] 

ASF GitHub Bot commented on SCB-785:
------------------------------------

jeremyxu2010 opened a new pull request #232: [SCB-785] 
支持在补偿方法里得到当前分布式事务的全局事务ID及本地事务ID
URL: https://github.com/apache/incubator-servicecomb-saga/pull/232
 
 
   Improve 支持在补偿方法里得到当前分布式事务的全局事务ID及本地事务ID
   
   1. 
补偿方法里通过omegaContext.globalTxId()和omegaContext.localTxId()可得到当前分布式事务的全局事务ID及本地
   事务ID
   
   Follow this checklist to help us incorporate your contribution quickly and 
easily:
   
    - [ x ] Make sure there is a [JIRA 
issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually 
before you start working on it).  Trivial changes like typos do not require a 
JIRA issue.  Your pull request should address just this issue, without pulling 
in other changes.
    - [ x ] Each commit in the pull request should have a meaningful subject 
line and body.
    - [ x ] Format the pull request title like `[SCB-XXX] Fixes bug in 
ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA 
issue.
    - [ x ] Write a pull request description that is detailed enough to 
understand what the pull request does, how, and why.
    - [ x ] Run `mvn clean install` to make sure basic checks pass. A more 
thorough check will be performed on your pull request automatically.
    - [ ] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   ---
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> 补偿方法里无法获取分布式事务的全局事务ID及本地事务ID
> ----------------------------
>
>                 Key: SCB-785
>                 URL: https://issues.apache.org/jira/browse/SCB-785
>             Project: Apache ServiceComb
>          Issue Type: Improvement
>          Components: Saga
>    Affects Versions: saga-0.2.0
>            Reporter: Jeremy Xu
>            Priority: Minor
>
> 因为在子事务业务处理方法中会将一部分中间数据存入外部缓存中,对应的补偿方法将可以通过这些中间数据进行合理的补偿操作,当时存入中间数据时会附带上globalTxId,
>  
> localTxId,后面将根据这个查找到之前存入的中间数据。但发现在业务方法中可以获取分布式事务的全局事务ID及本地事务ID,但对应的补偿方法里却不行。示例代码如下:
>  
> {code:java}
> @Autowired
> OmegaContext omegaContext;
> @Compensable(timeout=5, compensationMethod="cancel")
> public boolean transferOut(String from, int amount) {
>   // 这里可以获得
>   System.out.println(omegaContext.globalTxId());
>   System.out.println(omegaContext.localTxId());
>   repo.reduceBalanceByUsername(from, amount);
> }
> public boolean cancel(String from, int amount) {
>   // 这里不可以获得
>   System.out.println(omegaContext.globalTxId());
>   System.out.println(omegaContext.localTxId());
>   repo.addBalanceByUsername(from, amount);
> }
> {code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to