我正在使用基于注释的 Spring Retry。下面是我的界面:
public interface IRetriever
{
@Retryable(interceptor="RetryInterceptor")
public abstract List<Item> retrieve(final LogData transactionLogData, final RetrieveRequestType rqObject) throws InternalException, OpaqueExternalException;
}
共有三个类实现了这个接口来调用下游服务。我想定义 RetryInterceptors,这样对于每个下游调用,我应该能够定义一个单独的重试策略。本质上,我想在运行时更改 RetryInterceptor 。
在 Spring 中有没有一种方法可以在运行时更改 RetryInterceptor 并使代码使用特定的 RetryOperationsInterceptor?