Uploaded image for project: 'Apache ServiceComb'
  1. Apache ServiceComb
  2. SCB-1596

Support for defining OmegaContext parameters in @SagaStart and @Compensable methods

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • pack-0.7.0
    • Saga

    Description

      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

      @SagaStart
      public void booking(OmegaContext omegaContext)

      Unknown macro: {   omegaContext.globalTxId() }

      @Compensable(compensationMethod="cancel")
      public void car(OmegaContext omegaContext, String from, int amount)

       

      Practice @Autowired to inject OmegaContext 

      @Autowired OmegaContext omegaContext;

      @SagaStart
      public void booking()

      Unknown macro: {   omegaContext.globalTxId() }

      @Compensable(compensationMethod="cancel")
      public void car(String from, int amount)

       

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            zhanglei Lei Zhang

            Dates

              Created:
              Updated:

              Slack

                Issue deployment