我使用的是Spring Boot的RetryTemplate,如果无法连接,我尝试按第三方URL,然后我想重试。它在本地计算机上按预期工作,但是如果我在UAT上部署了我的应用程序并尝试重试它但它重试了更多然后提到的maxattempts,最后它给出了504 bad_gateway异常,对招摇没有任何反应? 任何人都可以帮助我
retryTemplate.execute(arg0 -> {
log.error("Sending Company Request to SIRA.");
final String xmlResponse = submitPayload(request, ResponseTimer, Client);
final ScreeningResponse screeningResponseFromXml = resultMapper
.getScreeningResponseFromXml(soapRequestXml, xmlResponse, screeningProvider, sourceDataId);
if (!screeningResponseFromXml.getErrors().isEmpty()
&& Arrays.asList(SiraRetryableFaultCode.values()).toString()
.contains(screeningResponseFromXml.getErrors().stream().findFirst().get().getCode())) {
throw new FraudFaultCodeException(screeningResponseFromXml.getErrors().stream().findFirst().get().getCode(),
sourceDataId, screeningResponseFromXml.getErrors().stream().findFirst().get().getMessage());
}
return screeningResponseFromXml;
});
=========我的重试配置文件====
@Configuration
public class RetryAppConfig {
@Bean
public RetryTemplate retryTemplate() {
RetryTemplate retryTemplate = new RetryTemplate();
FixedBackOffPolicy fixedBackOffPolicy = new FixedBackOffPolicy();
fixedBackOffPolicy.setBackOffPeriod(2000L);
retryTemplate.setBackOffPolicy(fixedBackOffPolicy);
ExceptionClassifierRetryPolicy exRetryPolicy = new ExceptionClassifierRetryPolicy();
exRetryPolicy.setPolicyMap(new HashMap<Class<? extends Throwable>, RetryPolicy>() {
{
put(RetryableException.class, new SimpleRetryPolicy(5));
put(FraudFaultCodeException.class, new SimpleRetryPolicy(5));
}
});
retryTemplate.setRetryPolicy(exRetryPolicy);
return retryTemplate;
}
}