Skip to content

Commit

Permalink
fix: removed circuitBreaker and retry and ignore properties for PDNDI…
Browse files Browse the repository at this point in the history
…mpresa
  • Loading branch information
gianmarcoplutino committed Oct 31, 2024
1 parent 7ea8867 commit 4a2aa27
Show file tree
Hide file tree
Showing 4 changed files with 211 additions and 259 deletions.
11 changes: 0 additions & 11 deletions app/src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,6 @@ resilience4j:
circuit-breaker-aspect-order: 1
instances:
geotaxCircuitbreaker:
wait-duration-in-open-state: 1m
permitted-number-of-calls-in-half-open-state: 3
sliding-window-type: count-based
sliding-window-size: 3
minimum-number-of-calls: 3
slow-call-duration-threshold: 10s
slow-call-rate-threshold: 60
failure-rate-threshold: 60
ignore-exceptions:
- it.pagopa.selfcare.party.registry_proxy.connector.exception.ResourceNotFoundException
pdndInfoCamereCircuitbreaker:
wait-duration-in-open-state: 1m
permitted-number-of-calls-in-half-open-state: 3
sliding-window-type: count-based
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package it.pagopa.selfcare.party.registry_proxy.connector.rest;

import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;
import io.github.resilience4j.retry.annotation.Retry;
import it.pagopa.selfcare.party.registry_proxy.connector.api.PDNDInfoCamereConnector;
import it.pagopa.selfcare.party.registry_proxy.connector.exception.ResourceNotFoundException;
import it.pagopa.selfcare.party.registry_proxy.connector.model.nationalregistriespdnd.PDNDBusiness;
import it.pagopa.selfcare.party.registry_proxy.connector.rest.client.PDNDInfoCamereRestClient;
import it.pagopa.selfcare.party.registry_proxy.connector.rest.config.PDNDInfoCamereRestClientConfig;
Expand All @@ -20,8 +17,6 @@
@Slf4j
@Service
public class PDNDInfoCamereConnectorImpl implements PDNDInfoCamereConnector {
public static final String ERROR_PDND_INFO_CAMERE_REST_CLIENT_MESSAGE =
"Error pdnd-infocamere rest client, message: %s";

private final PDNDInfoCamereRestClient pdndInfoCamereRestClient;
private final PDNDBusinessMapper pdndBusinessMapper;
Expand All @@ -40,10 +35,6 @@ public PDNDInfoCamereConnectorImpl(
}

@Override
@CircuitBreaker(
name = "pdndInfoCamereCircuitbreaker",
fallbackMethod = "fallbackRetrieveInstitutionByDescription")
@Retry(name = "retryServiceUnavailable")
public List<PDNDBusiness> retrieveInstitutionsPdndByDescription(String description) {
Assert.hasText(description, "Description is required");
ClientCredentialsResponse tokenResponse =
Expand All @@ -54,15 +45,7 @@ public List<PDNDBusiness> retrieveInstitutionsPdndByDescription(String descripti
return pdndBusinessMapper.toPDNDBusinesses(result);
}

public List<PDNDBusiness> fallbackRetrieveInstitutionByDescription(RuntimeException e) {
log.error(String.format(ERROR_PDND_INFO_CAMERE_REST_CLIENT_MESSAGE, e.getMessage()));
return List.of();
}

@Override
// @CircuitBreaker(name = "pdndInfoCamereCircuitbreaker", fallbackMethod =
// "fallbackRetrieveInstitutionByTaxCode")
// @Retry(name = "retryServiceUnavailable")
public PDNDBusiness retrieveInstitutionPdndByTaxCode(String taxCode) {
Assert.hasText(taxCode, "TaxCode is required");
ClientCredentialsResponse tokenResponse =
Expand All @@ -72,9 +55,4 @@ public PDNDBusiness retrieveInstitutionPdndByTaxCode(String taxCode) {
pdndInfoCamereRestClient.retrieveInstitutionPdndByTaxCode(taxCode, bearer).get(0);
return pdndBusinessMapper.toPDNDBusiness(result);
}

public PDNDBusiness fallbackRetrieveInstitutionByTaxCode(RuntimeException e) {
log.error(String.format(ERROR_PDND_INFO_CAMERE_REST_CLIENT_MESSAGE, e.getMessage()), e);
throw new ResourceNotFoundException("");
}
}
Original file line number Diff line number Diff line change
@@ -1,44 +1,48 @@
package it.pagopa.selfcare.party.registry_proxy.connector.rest.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class PDNDImpresa {

@JsonProperty("ProgressivoImpresa")
private long progressivoImpresa;
@JsonProperty("ProgressivoImpresa")
private long progressivoImpresa;

@JsonProperty("CodiceFiscale")
private String businessTaxId;
@JsonProperty("CodiceFiscale")
private String businessTaxId;

@JsonProperty("Denominazione")
private String businessName;
@JsonProperty("Denominazione")
private String businessName;

@JsonProperty("NaturaGiuridica")
private String legalNature;
@JsonProperty("NaturaGiuridica")
private String legalNature;

@JsonProperty("DescNaturaGiuridica")
private String legalNatureDescription;
@JsonProperty("DescNaturaGiuridica")
private String legalNatureDescription;

@JsonProperty("Cciaa")
private String cciaa;
@JsonProperty("Cciaa")
private String cciaa;

@JsonProperty("NRea")
private String nRea;
@JsonProperty("NRea")
private String nRea;

@JsonProperty("StatoImpresa")
private String businessStatus;
@JsonProperty("StatoImpresa")
private String businessStatus;

@JsonProperty("IndirizzoSedeLegale")
private PDNDSedeImpresa businessAddress;
@JsonProperty("IndirizzoSedeLegale")
private PDNDSedeImpresa businessAddress;

@JsonProperty("PEC")
private String digitalAddress;


public String getAddress() {
return businessAddress.getToponimoSede() + " " + businessAddress.getViaSede() + " " + businessAddress.getNcivicoSede();
}
@JsonProperty("PEC")
private String digitalAddress;

public String getAddress() {
return businessAddress.getToponimoSede()
+ " "
+ businessAddress.getViaSede()
+ " "
+ businessAddress.getNcivicoSede();
}
}
Loading

0 comments on commit 4a2aa27

Please sign in to comment.