我正在使用spring-retry和从https://launchdarkly.com/加载的配置。我们有这个功能标志服务,我可以在其中更改功能标志的配置,如maxAttempts和interval。但是,spring-retry不会对此做出反应。有没有办法检测这些新的配置?
示例如下:
这是重试方法:
@Retryable(
exceptionExpression = "#{@config.isInExceptionListForReExecution(#root)}",
maxAttemptsExpression = "#{@config.getMaxAttemptsForReExecution()}",
backoff = @Backoff(delayExpression = "#{@config.getIntervalBetweenReExecution()}"))
@Transactional(value = "transactionManagerDC")
public CustomRule executeWithRetry(CustomRule customRule, SyncObject oldObject, SyncObject newObject, CustomRuleType type, Map<String, Object> kafkaEvent, Boolean strictValidation) {
int retry = RetrySynchronizationManager.getContext().getRetryCount();
logger.info("Start executing process [{}] for object [{}] with Retry [{}]", customRule.getId(), objectId, retry);
}这是config bean,它注入特性标志服务并从标志中读取值。
@Service
class Config {
@Inject
private FeatureFlagService featureFlagService;
public boolean isInExceptionListForReExecution(Object exception1) {
String stringFlag = featureFlagService.getStringFlag("exceptionlist");
if (!stringFlag.contains(exception1.toString())) {
return true;
}
return false;
}
public int getMaxAttemptsForReExecution() {
int maxAttempts = featureFlagService.getIntFlag("maxAttempts");
return maxAttempts;
}
public int getIntervalBetweenReExecution() {
int interval = featureFlagService.getIntFlag("interval");
return interval;
}
}正如您所看到的,config bean将从标志中检索所有配置。现在,第一次configs检索的内容将被保留。如果我更改了配置,则不会考虑尝试和积分。如何检测这种变化?或者需要为此重新启动应用程序。
发布于 2021-09-09 14:07:32
在上下文初始化期间,配置表达式只计算一次。
有一个开放的新功能请求,用于在运行时对其进行评估。
https://stackoverflow.com/questions/69117814
复制相似问题