com.alibaba.easyretry.core.PersistenceRetryer Maven / Gradle / Ivy
package com.alibaba.easyretry.core;
import com.alibaba.easyretry.common.SCallable;
import com.alibaba.easyretry.common.processor.AsyncPersistenceProcessor;
import com.alibaba.easyretry.common.retryer.Retryer;
import com.alibaba.easyretry.common.retryer.RetryerInfo;
import com.alibaba.easyretry.core.process.async.before.ExceptionPersistenceAsyncBeforeRetryProcessor;
import com.alibaba.easyretry.core.process.async.before.ResultAsynPersistenceBeforeRetryProcessor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
/**
* @author Created by wuhao on 2020/11/1.
*/
@Slf4j
@Data
public class PersistenceRetryer implements Retryer {
private RetryerInfo retryerInfo;
public PersistenceRetryer(RetryerInfo retryerInfo) {
this.retryerInfo = retryerInfo;
}
@Override
public V call(SCallable callable) throws Throwable {
AsyncPersistenceProcessor asynPersistenceProcessor;
try {
V result = callable.call();
asynPersistenceProcessor = new ResultAsynPersistenceBeforeRetryProcessor<>(result,
retryerInfo);
} catch (Throwable e) {
log.error(
"call method error executorMethodName is {} executorName name is {} args is {}",
retryerInfo.getExecutorMethodName(),
retryerInfo.getExecutorName(),
retryerInfo.getArgs(),
e);
asynPersistenceProcessor = new ExceptionPersistenceAsyncBeforeRetryProcessor<>(e,
retryerInfo);
}
asynPersistenceProcessor.process();
return asynPersistenceProcessor.getResult();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy