伪造客户端检索器



我只是想从应用程序中读取retryInterval和retryMaxAttempt。属性像@Value()不是静态值,我怎么能使它

@Slf4j
@Component
@NoArgsConstructor
public class FeignConnectionRetryer implements Retryer {
private int retryMaxAttempt;
private long retryInterval;
private int attempt = 1;

public FeignConnectionRetryer(int retryMaxAttempt, Long retryInterval) {
this.retryMaxAttempt = retryMaxAttempt;
this.retryInterval = retryInterval;
}
@Override
public void continueOrPropagate(RetryableException e) {
log.info("Feign retry attempt {} due to {} ", attempt, e.getMessage());
if (attempt++ == retryMaxAttempt)
throw e;
try {
Thread.sleep(retryInterval);
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
}
}
@Override
public Retryer clone() {
return new FeignConnectionRetryer(3, 2000L);
}
}

如果我正确理解了你的问题,让你的构造函数看起来像这样,并把feign.retry.attemptsfeign.retry.interval属性放在你的应用程序中。属性文件

public FeignConnectionRetryer(
@Value("${feign.retry.attempts:3}") Integer maxAttempts,
@Value("${feign.retry.interval:2000}") Long interval
)

相关内容

  • 没有找到相关文章

最新更新