【发布时间】:2022-06-20 15:57:51
【问题描述】:
我在 spring 中有一个自定义注释,它利用了@Retryable 注释
@Target({ ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Retryable(value = MyClass.SubClassException.class,
backoff = @Backoff(random = true,
delayExpression = "#{${retry.delayExpression}}",
maxDelayExpression = "#{${retry.maxDelay}}",
multiplierExpression = "#{${retry.multiplier}}"),
maxAttemptsExpression = "#{${retry.maxRetryAttempts}}")
public @interface CustomRetryable {
int delayMilliSeconds() default 1000;
int maxDelayMilliSeconds() default 1000;
int multiplier() default 2;
int retryAttempts() default 3;
Class<? extends Throwable>[] exceptionType();
}
我想做的是能够用一个类和可能的readTimeout 和其他值调用我的注释,并将这些传递给@Retryable 注释。这可能吗?
我想做这样的事情:
@GlobalRetryable(exceptionType = MyCustom.SubClassException.class,
delayMilliSeconds = 10)
Foo bar(Foozie request){
// some impl heere
}
但我找不到将MyCustom.SubClassException.class 之类的东西传递给Retryable 注释的方法。
【问题讨论】: