in omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/ForwardRecovery.java [42:75]
public Object applyTo(ProceedingJoinPoint joinPoint, Compensable compensable, CompensableInterceptor interceptor,
OmegaContext context, String parentTxId, int forwardRetries) throws Throwable {
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
int remains = forwardRetries;
try {
while (true) {
try {
return super.applyTo(joinPoint, compensable, interceptor, context, parentTxId, remains);
} catch (Throwable throwable) {
if (throwable instanceof InvalidTransactionException) {
throw throwable;
}
remains--;
if (remains == 0) {
LOG.error(
"Forward Retried sub tx failed maximum times, global tx id: {}, local tx id: {}, method: {}, retried times: {}",
context.globalTxId(), context.localTxId(), method.toString(), forwardRetries);
throw throwable;
}
LOG.warn("Forward Retrying sub tx failed, global tx id: {}, local tx id: {}, method: {}, remains: {}",
context.globalTxId(), context.localTxId(), method.toString(), remains);
Thread.sleep(compensable.retryDelayInMilliseconds());
}
}
} catch (InterruptedException e) {
String errorMessage = "Failed to handle tx because it is interrupted, global tx id: " + context.globalTxId()
+ ", local tx id: " + context.localTxId() + ", method: " + method.toString();
LOG.error(errorMessage);
interceptor.onError(parentTxId, compensationMethodSignature(joinPoint, compensable, method), e);
throw new OmegaException(errorMessage);
}
}