Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
[SELC-4883] feat: add retry on retrieveGeographicTaxonomies (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
giulia-tremolada authored May 27, 2024
1 parent dde16c8 commit f174047
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
9 changes: 9 additions & 0 deletions app/src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions connector/rest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
</dependency>
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-spring-boot2</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit f174047

Please sign in to comment.