diff --git a/app/src/main/resources/config/application.yml b/app/src/main/resources/config/application.yml index e2d0644f..ebc4a012 100644 --- a/app/src/main/resources/config/application.yml +++ b/app/src/main/resources/config/application.yml @@ -49,3 +49,12 @@ core: type: ${CORE_USER_EVENT_SERVICE_TYPE:ignore} contract-event-service: type: ${CORE_CONTRACT_EVENT_SERVICE_TYPE:ignore} + resilience4j: + retry: + retry-aspect-order: 1 + instances: + retryTimeout: + max-attempts: 3 + wait-duration: 5s + retry-exceptions: + - feign.RetryableException \ No newline at end of file diff --git a/connector/rest/pom.xml b/connector/rest/pom.xml index 985c728a..dd13b276 100644 --- a/connector/rest/pom.xml +++ b/connector/rest/pom.xml @@ -30,6 +30,10 @@ io.github.openfeign feign-okhttp + + io.github.resilience4j + resilience4j-spring-boot2 + diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/PartyRegistryProxyConnectorImpl.java b/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/PartyRegistryProxyConnectorImpl.java index a0eb2abb..0053c3ca 100644 --- a/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/PartyRegistryProxyConnectorImpl.java +++ b/connector/rest/src/main/java/it/pagopa/selfcare/mscore/connector/rest/PartyRegistryProxyConnectorImpl.java @@ -1,6 +1,7 @@ package it.pagopa.selfcare.mscore.connector.rest; import feign.FeignException; +import io.github.resilience4j.retry.annotation.Retry; import it.pagopa.selfcare.commons.base.logging.LogUtils; import it.pagopa.selfcare.mscore.api.PartyRegistryProxyConnector; import it.pagopa.selfcare.mscore.connector.rest.client.PartyRegistryProxyRestClient; @@ -30,6 +31,7 @@ @Service public class PartyRegistryProxyConnectorImpl implements PartyRegistryProxyConnector { + public static final String CODE_IS_REQUIRED = "Code is required"; private final PartyRegistryProxyRestClient restClient; private final AooMapper aooMapper; private final UoMapper uoMapper; @@ -137,9 +139,10 @@ private CategoryProxyInfo convertCategoryProxyInfo(ProxyCategoryResponse respons } @Override + @Retry(name = "retryTimeout") public GeographicTaxonomies getExtByCode(String code) { log.debug(LogUtils.CONFIDENTIAL_MARKER, "getExtByCode code = {}", code); - Assert.hasText(code, "Code is required"); + Assert.hasText(code, CODE_IS_REQUIRED); GeographicTaxonomiesResponse result = restClient.getExtByCode(code); log.debug(LogUtils.CONFIDENTIAL_MARKER, "getExtByCode result = {}", result); return toGeoTaxonomies(result); @@ -148,7 +151,7 @@ public GeographicTaxonomies getExtByCode(String code) { @Override public AreaOrganizzativaOmogenea getAooById(String aooId) { log.debug("getAooById id = {}", aooId); - Assert.hasText(aooId, "Code is required"); + Assert.hasText(aooId, CODE_IS_REQUIRED); AooResponse result = restClient.getAooById(aooId); log.debug("getAooById id = {}", aooId); return aooMapper.toEntity(result); @@ -157,7 +160,7 @@ public AreaOrganizzativaOmogenea getAooById(String aooId) { @Override public UnitaOrganizzativa getUoById(String uoId) { log.debug("getUoById id = {}", uoId); - Assert.hasText(uoId, "Code is required"); + Assert.hasText(uoId, CODE_IS_REQUIRED); UoResponse result = restClient.getUoById(uoId); log.debug("getUoById id = {}", uoId); return uoMapper.toEntity(result);