[ 
https://issues.apache.org/jira/browse/SCB-1596?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Willem Jiang updated SCB-1596:
------------------------------
    Labels: easyfix  (was: )

> Support for defining OmegaContext parameters in @SagaStart and @Compensable 
> methods
> -----------------------------------------------------------------------------------
>
>                 Key: SCB-1596
>                 URL: https://issues.apache.org/jira/browse/SCB-1596
>             Project: Apache ServiceComb
>          Issue Type: Improvement
>          Components: Saga
>            Reporter: Lei Zhang
>            Priority: Major
>              Labels: easyfix
>             Fix For: pack-0.7.0
>
>
> Sometimes users need to get the GlobalTxId or LocalTxId in the business code. 
> Currently, practice is to use @Autowired to inject OmegaContext, I suggest 
> referring to the way SpringMvc injects HttpServletRequest
>  
> Usually, the OmegaContext parameter is declared in a method that is not 
> needed. If the user declares the parameter we can pass this value in 
> SagaStartAspect or TransactionAspect
>  
> The following code shows the usage of the OmegaContext parameters. Both ways 
> are OK,
> Practice OmegaContext parameter in methods
> {quote}@SagaStart 
> public void booking(OmegaContext omegaContext) { 
>   omegaContext.globalTxId() 
> } 
> @Compensable(compensationMethod="cancel") 
> public void car(OmegaContext omegaContext, String from, int amount) { 
>   omegaContext.globalTxId() 
> }
> {quote}
>  
> Practice @Autowired to inject OmegaContext 
> {quote}@Autowired OmegaContext omegaContext;
> @SagaStart 
> public void booking() { 
>   omegaContext.globalTxId() 
> } 
> @Compensable(compensationMethod="cancel") 
> public void car(String from, int amount) { 
>   omegaContext.globalTxId() 
> }
> {quote}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to