You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@servicecomb.apache.org by "Willem Jiang (Jira)" <ji...@apache.org> on 2020/05/29 00:35:00 UTC
[jira] [Updated] (SCB-1596) Support for defining OmegaContext
parameters in @SagaStart and @Compensable methods
[ https://issues.apache.org/jira/browse/SCB-1596?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Willem Jiang updated SCB-1596:
------------------------------
Fix Version/s: pack-0.7.0
> 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
> 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)