@Test public void newLocalTxIdInCompensable() throws Throwable { aspect.advise(joinPoint, compensable); TxEvent startedEvent = messages.get(0); assertThat(startedEvent.globalTxId(), is(globalTxId)); assertThat(startedEvent.localTxId(), is(newLocalTxId)); assertThat(startedEvent.parentTxId(), is(localTxId)); assertThat(startedEvent.type(), is(EventType.TxStartedEvent)); assertThat(startedEvent.retries(), is(0)); assertThat(startedEvent.retryMethod().isEmpty(), is(true)); TxEvent endedEvent = messages.get(1); assertThat(endedEvent.globalTxId(), is(globalTxId)); assertThat(endedEvent.localTxId(), is(newLocalTxId)); assertThat(endedEvent.parentTxId(), is(localTxId)); assertThat(endedEvent.type(), is(EventType.TxEndedEvent)); assertThat(omegaContext.globalTxId(), is(globalTxId)); assertThat(omegaContext.localTxId(), is(localTxId)); }
@Around("execution(@org.apache.servicecomb.saga.omega.transaction.annotations.Compensable * *(..)) && @annotation(compensable)") Object advise(ProceedingJoinPoint joinPoint, Compensable compensable) throws Throwable { Method method = ((MethodSignature) joinPoint.getSignature()).getMethod(); String localTxId = context.localTxId(); context.newLocalTxId(); LOG.debug("Updated context {} for compensable method {} ", context, method.toString()); int retries = compensable.retries(); RecoveryPolicy recoveryPolicy = RecoveryPolicyFactory.getRecoveryPolicy(retries); try { return recoveryPolicy.apply(joinPoint, compensable, interceptor, context, localTxId, retries); } catch (Exception e) { throw e; } finally { context.setLocalTxId(localTxId); LOG.debug("Restored context back to {}", context); } }
TransactionAspect { @Around("execution(@org.apache.servicecomb.saga.omega.transaction.annotations.Compensable * *(..)) && @annotation(compensable)") Object advise(ProceedingJoinPoint joinPoint, Compensable compensable) throws Throwable { Method method = ((MethodSignature) joinPoint.getSignature()).getMethod(); String localTxId = context.localTxId(); context.newLocalTxId(); LOG.debug("Updated context {} for compensable method {} ", context, method.toString()); int retries = compensable.retries(); RecoveryPolicy recoveryPolicy = RecoveryPolicyFactory.getRecoveryPolicy(retries); try { return recoveryPolicy.apply(joinPoint, compensable, interceptor, context, localTxId, retries); } catch (Exception e) { throw e; } finally { context.setLocalTxId(localTxId); LOG.debug("Restored context back to {}", context); } } }
TransactionAspect { @Around("execution(@org.apache.servicecomb.saga.omega.transaction.annotations.Compensable * *(..)) && @annotation(compensable)") Object advise(ProceedingJoinPoint joinPoint, Compensable compensable) throws Throwable { Method method = ((MethodSignature) joinPoint.getSignature()).getMethod(); String localTxId = context.localTxId(); context.newLocalTxId(); LOG.debug("Updated context {} for compensable method {} ", context, method.toString()); int retries = compensable.retries(); RecoveryPolicy recoveryPolicy = RecoveryPolicyFactory.getRecoveryPolicy(retries); try { return recoveryPolicy.apply(joinPoint, compensable, interceptor, context, localTxId, retries); } catch (Exception e) { throw e; } finally { context.setLocalTxId(localTxId); LOG.debug("Restored context back to {}", context); } } TransactionAspect(MessageSender sender, OmegaContext context); }
TransactionAspect { @Around("execution(@org.apache.servicecomb.saga.omega.transaction.annotations.Compensable * *(..)) && @annotation(compensable)") Object advise(ProceedingJoinPoint joinPoint, Compensable compensable) throws Throwable { Method method = ((MethodSignature) joinPoint.getSignature()).getMethod(); String localTxId = context.localTxId(); context.newLocalTxId(); LOG.debug("Updated context {} for compensable method {} ", context, method.toString()); int retries = compensable.retries(); RecoveryPolicy recoveryPolicy = RecoveryPolicyFactory.getRecoveryPolicy(retries); try { return recoveryPolicy.apply(joinPoint, compensable, interceptor, context, localTxId, retries); } catch (Exception e) { throw e; } finally { context.setLocalTxId(localTxId); LOG.debug("Restored context back to {}", context); } } TransactionAspect(MessageSender sender, OmegaContext context);  }
TransactionAspect { @Around("execution(@org.apache.servicecomb.saga.omega.transaction.annotations.Compensable * *(..)) && @annotation(compensable)") Object advise(ProceedingJoinPoint joinPoint, Compensable compensable) throws Throwable { Method method = ((MethodSignature) joinPoint.getSignature()).getMethod(); String localTxId = context.localTxId(); context.newLocalTxId(); LOG.debug("Updated context {} for compensable method {} ", context, method.toString()); int retries = compensable.retries(); RecoveryPolicy recoveryPolicy = RecoveryPolicyFactory.getRecoveryPolicy(retries); try { return recoveryPolicy.apply(joinPoint, compensable, interceptor, context, localTxId, retries); } catch (Exception e) { throw e; } finally { context.setLocalTxId(localTxId); LOG.debug("Restored context back to {}", context); } } TransactionAspect(MessageSender sender, OmegaContext context);   }