Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
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)