From 6bf1185458b936a0da7664f9b28e5bca8e66cfd5 Mon Sep 17 00:00:00 2001 From: manuraf Date: Thu, 4 Apr 2024 20:05:46 +0200 Subject: [PATCH 1/4] retry with resilience4j --- app/src/main/resources/config/application.yml | 11 +++++++++++ connector/rest/pom.xml | 4 ++++ .../connector/OnboardingMsConnectorImpl.java | 10 ++++++++++ 3 files changed, 25 insertions(+) diff --git a/app/src/main/resources/config/application.yml b/app/src/main/resources/config/application.yml index c7b06ab9..17480a19 100644 --- a/app/src/main/resources/config/application.yml +++ b/app/src/main/resources/config/application.yml @@ -29,3 +29,14 @@ logging: it.pagopa.selfcare: ${B4F_ONBOARDING_LOG_LEVEL:DEBUG} pattern: additional-info: ",%X{X-Client-Ip:-}]" + + +resilience4j: + retry: + retry-aspect-order: 1 + instances: + retryTimeout: + max-attempts: 3 + wait-duration: 5s + retry-exceptions: + - feign.RetryableException diff --git a/connector/rest/pom.xml b/connector/rest/pom.xml index 7a8b624c..5a83f459 100644 --- a/connector/rest/pom.xml +++ b/connector/rest/pom.xml @@ -36,6 +36,10 @@ jackson-databind-nullable 0.2.4 + + io.github.resilience4j + resilience4j-spring-boot2 + diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/onboarding/connector/OnboardingMsConnectorImpl.java b/connector/rest/src/main/java/it/pagopa/selfcare/onboarding/connector/OnboardingMsConnectorImpl.java index 4eac6f30..78b710ff 100644 --- a/connector/rest/src/main/java/it/pagopa/selfcare/onboarding/connector/OnboardingMsConnectorImpl.java +++ b/connector/rest/src/main/java/it/pagopa/selfcare/onboarding/connector/OnboardingMsConnectorImpl.java @@ -1,5 +1,6 @@ package it.pagopa.selfcare.onboarding.connector; +import io.github.resilience4j.retry.annotation.Retry; import it.pagopa.selfcare.commons.base.utils.InstitutionType; import it.pagopa.selfcare.onboarding.connector.api.OnboardingMsConnector; import it.pagopa.selfcare.onboarding.connector.model.onboarding.OnboardingData; @@ -32,6 +33,7 @@ public OnboardingMsConnectorImpl(MsOnboardingApiClient msOnboardingApiClient, Ms } @Override + @Retry(name = "retryTimeout") public void onboarding(OnboardingData onboardingData) { if (onboardingData.getInstitutionType() == InstitutionType.PA) { msOnboardingApiClient._v1OnboardingPaPost(onboardingMapper.toOnboardingPaRequest(onboardingData)); @@ -44,26 +46,31 @@ public void onboarding(OnboardingData onboardingData) { @Override + @Retry(name = "retryTimeout") public void onboardingCompany(OnboardingData onboardingData) { msOnboardingApiClient._v1OnboardingPgCompletionPost(onboardingMapper.toOnboardingPgRequest(onboardingData)); } @Override + @Retry(name = "retryTimeout") public void onboardingTokenComplete(String onboardingId, MultipartFile contract) { msOnboardingApiClient._v1OnboardingOnboardingIdCompletePut(onboardingId, contract); } @Override + @Retry(name = "retryTimeout") public void onboardingPending(String onboardingId) { msOnboardingApiClient._v1OnboardingOnboardingIdPendingGet(onboardingId); } @Override + @Retry(name = "retryTimeout") public void approveOnboarding(String onboardingId) { msOnboardingApiClient._v1OnboardingOnboardingIdApprovePut(onboardingId); } @Override + @Retry(name = "retryTimeout") public void rejectOnboarding(String onboardingId, String reason) { ReasonRequest reasonForReject = new ReasonRequest(); reasonForReject.setReasonForReject(reason); @@ -71,18 +78,21 @@ public void rejectOnboarding(String onboardingId, String reason) { } @Override + @Retry(name = "retryTimeout") public OnboardingData getOnboarding(String onboardingId) { OnboardingGet onboardingGet = msOnboardingApiClient._v1OnboardingOnboardingIdGet(onboardingId).getBody(); return onboardingMapper.toOnboardingData(onboardingGet); } @Override + @Retry(name = "retryTimeout") public OnboardingData getOnboardingWithUserInfo(String onboardingId) { OnboardingGet onboardingGet = msOnboardingApiClient._v1OnboardingOnboardingIdWithUserInfoGet(onboardingId).getBody(); return onboardingMapper.toOnboardingData(onboardingGet); } @Override + @Retry(name = "retryTimeout") public Resource getContract(String onboardingId) { return msOnboardingTokenApiClient._v1TokensOnboardingIdContractGet(onboardingId).getBody(); } From d1bef052b463bf786d061c8724a29236f8a33e0e Mon Sep 17 00:00:00 2001 From: manuraf Date: Thu, 4 Apr 2024 20:06:12 +0200 Subject: [PATCH 2/4] decrease timeout connection --- helm/pnpg/values-prod.yaml | 6 +++--- helm/values-prod.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/helm/pnpg/values-prod.yaml b/helm/pnpg/values-prod.yaml index e693030a..848ddb3a 100644 --- a/helm/pnpg/values-prod.yaml +++ b/helm/pnpg/values-prod.yaml @@ -13,7 +13,7 @@ ingress: hosts: - host: "prod01.pnpg.internal.selfcare.pagopa.it" paths: - - path: /onboarding/(.*) + - path: /imprese/onboarding/(.*) pathType: ImplementationSpecific autoscaling: @@ -29,6 +29,6 @@ configEnvSpecific: B4F_ONBOARDING_LOG_LEVEL: "INFO" REST_CLIENT_LOGGER_LEVEL: "BASIC" ONBOARDING_ALLOWED_INSTITUTIONS_PRODUCTS: "{'prod-pn-pg':{'*'}}" - MS_ONBOARDING_URL: "https://selc-p-pnpg-onboarding-ms-ca.salmonpond-60269923.westeurope.azurecontainerapps.io" + MS_ONBOARDING_URL: "selc-p-pnpg-onboardingbackend-ca.redbeach-5da5166f.westeurope.azurecontainerapps.io" REST_CLIENT_READ_TIMEOUT: "60000" - REST_CLIENT_CONNECT_TIMEOUT: "60000" + REST_CLIENT_CONNECT_TIMEOUT: "5000" diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index b06c7966..3c1ac57d 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -45,4 +45,4 @@ configEnvSpecific: MS_ONBOARDING_URL: "https://selc-p-onboarding-ms-ca.salmonstone-7f910b8f.westeurope.azurecontainerapps.io" ONBOARDING_ALLOWED_INSTITUTIONS_PRODUCTS: "{'prod-interop':{'*'},'prod-pn':{'*'},'prod-pagopa':{'*'},'prod-io':{'*'},'prod-io-premium':{'*'},'prod-io-sign':{'*'},'prod-sendino':{'*'},'prod-fd':{'*'},'prod-fd-garantito':{'*'}}" REST_CLIENT_READ_TIMEOUT: "60000" - REST_CLIENT_CONNECT_TIMEOUT: "60000" + REST_CLIENT_CONNECT_TIMEOUT: "5000" From c5a460e4db740921d6921518a8b251212415a90a Mon Sep 17 00:00:00 2001 From: manuraf Date: Thu, 4 Apr 2024 20:10:40 +0200 Subject: [PATCH 3/4] fix https --- helm/pnpg/values-prod.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/pnpg/values-prod.yaml b/helm/pnpg/values-prod.yaml index 848ddb3a..e1b9a32a 100644 --- a/helm/pnpg/values-prod.yaml +++ b/helm/pnpg/values-prod.yaml @@ -29,6 +29,6 @@ configEnvSpecific: B4F_ONBOARDING_LOG_LEVEL: "INFO" REST_CLIENT_LOGGER_LEVEL: "BASIC" ONBOARDING_ALLOWED_INSTITUTIONS_PRODUCTS: "{'prod-pn-pg':{'*'}}" - MS_ONBOARDING_URL: "selc-p-pnpg-onboardingbackend-ca.redbeach-5da5166f.westeurope.azurecontainerapps.io" + MS_ONBOARDING_URL: "https://selc-p-pnpg-onboardingbackend-ca.redbeach-5da5166f.westeurope.azurecontainerapps.io" REST_CLIENT_READ_TIMEOUT: "60000" REST_CLIENT_CONNECT_TIMEOUT: "5000" From 9431e88c751557622f7858ccad743dc475d76065 Mon Sep 17 00:00:00 2001 From: manuraf Date: Thu, 4 Apr 2024 20:12:29 +0200 Subject: [PATCH 4/4] fix pnpg onboarding ms url --- helm/pnpg/values-prod.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/pnpg/values-prod.yaml b/helm/pnpg/values-prod.yaml index e1b9a32a..7649657c 100644 --- a/helm/pnpg/values-prod.yaml +++ b/helm/pnpg/values-prod.yaml @@ -29,6 +29,6 @@ configEnvSpecific: B4F_ONBOARDING_LOG_LEVEL: "INFO" REST_CLIENT_LOGGER_LEVEL: "BASIC" ONBOARDING_ALLOWED_INSTITUTIONS_PRODUCTS: "{'prod-pn-pg':{'*'}}" - MS_ONBOARDING_URL: "https://selc-p-pnpg-onboardingbackend-ca.redbeach-5da5166f.westeurope.azurecontainerapps.io" + MS_ONBOARDING_URL: "https://selc-p-pnpg-onboarding-ms-ca.redbeach-5da5166f.westeurope.azurecontainerapps.io" REST_CLIENT_READ_TIMEOUT: "60000" REST_CLIENT_CONNECT_TIMEOUT: "5000"