Skip to content

Commit 2a3ff20

Browse files
martiMatteimottoneFeliceMentemichelescaradamiano.lozzi
authored
Feature/tech bingq3.3 (#581)
* PN-13378: enabled EnableKeyRotation * Bug/pn 10717 (#573) * PN-10717: Introduced retry strategy into state machine calls. * PN-10717: Fixed statemachine retry strategy property names * PN-10717: changed value of PnEcPECMaxMessageSizeMB to 30 * PN-10717: fixed UoM of SpringCodecMaxInMemorySize --------- Co-authored-by: michelescara <michele.scaramuzzino@gmail.com> Co-authored-by: damiano.lozzi <damiano.lozzi@dgsspa.com> Co-authored-by: Mario Ottone <mario.ottone@dgsspa.com> * Hotfix/pn 11619 (#574) * PN-11619: PaId correction * PN-11619: comparison test added * PN-11619: fixed typo in yml --------- Co-authored-by: ElenaPagnacco <116713610+ElenaPagnacco@users.noreply.github.com> Co-authored-by: michelescara <michele.scaramuzzino@gmail.com> * Hotfix/pn 12231 (#575) * PN-12231: Fixed gestioneRetryPecScheduler interrupting when receiving empty value from filterRequestPec() method. * PN-12231: Added fix to other channels --------- Co-authored-by: michelescara <michele.scaramuzzino@gmail.com> * PN-13231 remove hardcoded account (#576) * Feature/pn 9104 (#572) * PN-9104: Completed red phase. Added metric dimensions parser and configuration. Added new metrics in CloudWatchMetricPublisherConfiguration. Fixed executeAndPublishResponseTime() method to handle both valued and void monos. * PN-9104: Completed green phase. Finalized MetricsDimensionConfiguration. * PN-9104: Fixed dimension wrong casting. * PN-9104: addressed sonarcloud issues * feature/PN-9104 fix merge --------- Co-authored-by: michelescara <michele.scaramuzzino@gmail.com> Co-authored-by: damiano.lozzi <damiano.lozzi@dgsspa.com> * PN-9104-bis fix microservice-dev-cfg.json (#577) * PN-10717: Fixed error mapping in CallMacchinaStati. (#578) Added junit tests. * PN-12231: Fixed errore handling in gestioneRetryEmail. (#579) * PN-12231: Fixed errore handling in gestioneRetryEmail. Added handling of empty return in processOnlyBodyRetry method. * PN-12231: Added missing log. * Feature/pn 12231 bis (#580) * PN-12231: Fixed errore handling in gestioneRetryEmail. Added handling of empty return in processOnlyBodyRetry method. * PN-12231: Added missing log. * PN-12231: Fixed error handling in gestioneRetry schedulers. * PN-12231: Fixed @DirtiesContext annotation. Moved cleanup logic in @beforeeach method. --------- Co-authored-by: mottone <mottone@email.it> Co-authored-by: Marco Iannaccone <marco.iannaccone@pagopa.it> Co-authored-by: michelescara <michele.scaramuzzino@gmail.com> Co-authored-by: damiano.lozzi <damiano.lozzi@dgsspa.com> Co-authored-by: Mario Ottone <mario.ottone@dgsspa.com> Co-authored-by: ElenaPagnacco <116713610+ElenaPagnacco@users.noreply.github.com> Co-authored-by: michelescara <79908782+michelescara@users.noreply.github.com>
1 parent 3bf022b commit 2a3ff20

File tree

34 files changed

+690
-129
lines changed

34 files changed

+690
-129
lines changed

docs/openapi/external/consolidatore-v1.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ components:
484484
required:
485485
- requestId
486486
- requestSenderId
487-
- requestPAId
487+
- requestPaId
488488
- clientRequestTimeStamp
489489
- eventType
490490
- productType

pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,20 @@
343343
<version>2.1.3</version>
344344
</dependency>
345345

346+
<dependency>
347+
<groupId>com.squareup.okhttp3</groupId>
348+
<artifactId>okhttp</artifactId>
349+
<version>4.12.0</version>
350+
<scope>test</scope>
351+
</dependency>
352+
353+
<dependency>
354+
<groupId>com.squareup.okhttp3</groupId>
355+
<artifactId>mockwebserver</artifactId>
356+
<version>4.12.0</version>
357+
<scope>test</scope>
358+
</dependency>
359+
346360
<!--prova generators-->
347361

348362
</dependencies>

scripts/aws/cfn/microservice-dev-cfg.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"PnECPaperPAIdToRaster": "15376371009",
4949
"PnECPaperPAIdOverride": "15376371009",
5050
"SQSMaxBatchSubscribedMsgs": "20",
51+
"PnEcPecMetricsSchema": "Pn-EC-Pec-MetricsSchema",
5152
"SQSCartaceoMaxBatchSubscribedMsgs": "10"
5253
}
5354
}

scripts/aws/cfn/microservice.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ Parameters:
7070
Type: String
7171
Description: 'Secret ID for Identity Pec'
7272

73+
PnEcPecMetricsSchema:
74+
Type: String
75+
Description: 'Name of the AWS parameter that contains the schema for the metric dimensions of pec services'
76+
7377
# Version:
7478
# Type: String
7579
# Description: 'keep track of used projects commitIds'
@@ -1046,7 +1050,8 @@ Resources:
10461050
ContainerEnvEntry79: !Sub 'PnEcQueueNameTrackerStatoSERCQ=${PnEcQueueNameTrackerStatoSERCQ}'
10471051
ContainerEnvEntry80: !Sub 'PnEcQueueNameTrackerErroriSERCQ=${PnEcQueueNameTrackerErroriSERCQ}'
10481052
ContainerEnvEntry81: !Sub 'SQSMaxBatchSubscribedMsgs=${SQSMaxBatchSubscribedMsgs}'
1049-
ContainerEnvEntry82: !Sub 'SQSCartaceoMaxBatchSubscribedMsgs=${SQSCartaceoMaxBatchSubscribedMsgs}'
1053+
ContainerEnvEntry82: !Sub 'PnEcPecMetricsSchema=${PnEcPecMetricsSchema}'
1054+
ContainerEnvEntry83: !Sub 'SQSCartaceoMaxBatchSubscribedMsgs=${SQSCartaceoMaxBatchSubscribedMsgs}'
10501055
ContainerSecret1: !Sub 'ConsolidatoreClientApiKey=arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:pn-EC-Secrets:ConsolidatoreClientApiKey:AWSCURRENT:'
10511056
MicroServiceSecretPrefix: pn-EC-Secrets
10521057
MappedPaths: '/external-channels/*,/external-channel/*,/consolidatore-ingress/*'
@@ -1507,7 +1512,7 @@ Resources:
15071512
- !Ref PnEcAlarmArnDLQueueTrackerStatoSERCQ
15081513
- !Ref PnEcAlarmArnQueueTrackerErroriSERCQ
15091514
- !Ref PnEcAlarmArnDLQueueTrackerErroriSERCQ
1510-
- !Ref PnEcAlarmArnEventsDLQueuePnCoreTargetEventBus
1515+
- !Ref PnEcAlarmArnEventsDLQueuePnCoreTargetEventBus
15111516
DynamoDBTableNames:
15121517
!Join
15131518
- ','

scripts/aws/cfn/storage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Resources:
5959
Description: A symmetric encryption KMS key AES-256-GCM
6060
KeySpec: SYMMETRIC_DEFAULT
6161
KeyUsage: ENCRYPT_DECRYPT
62+
EnableKeyRotation: true
6263
KeyPolicy:
6364
Version: 2012-10-17
6465
Statement:

src/main/java/it/pagopa/pn/ec/EcApplication.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@
6767
//SQS
6868
@PropertySource("classpath:sqs/sqs.properties")
6969

70+
//STATE MACHINE
71+
@PropertySource("classpath:statemachine/statemachine.properties")
72+
7073
//NAMIRIAL
7174
@PropertySource("classpath:namirial/namirial.properties")
7275

src/main/java/it/pagopa/pn/ec/cartaceo/service/CartaceoService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ void gestioneRetryCartaceoScheduler() {
283283
.flatMap(cartaceoPresaInCaricoInfoSqsMessageWrapper -> gestioneRetryCartaceo(cartaceoPresaInCaricoInfoSqsMessageWrapper.getMessageContent(),
284284
cartaceoPresaInCaricoInfoSqsMessageWrapper.getMessage()))
285285
.map(MonoResultWrapper::new)
286+
.doOnError(throwable -> log.error(GENERIC_ERROR, throwable))
287+
// Restituiamo una DeleteMessageResponse vuota per non bloccare lo scaricamento dalla coda
288+
.onErrorResume(throwable -> Mono.just(new MonoResultWrapper<>(DeleteMessageResponse.builder().build())))
286289
.defaultIfEmpty(new MonoResultWrapper<>(null))
287290
.repeat()
288291
.takeWhile(MonoResultWrapper::isNotEmpty)
@@ -642,4 +645,4 @@ public Mono<SendMessageResponse> sendNotificationOnBatchQueue(PresaInCaricoInfo
642645
return sqsService.send(cartaceoSqsQueueName.batchName(), presaInCaricoInfo);
643646
}
644647

645-
}
648+
}

src/main/java/it/pagopa/pn/ec/commons/configuration/aws/cloudwatch/CloudWatchMetricPublisherConfiguration.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22

33
import it.pagopa.pn.ec.commons.exception.cloudwatch.CloudWatchResourceNotFoundException;
44
import it.pagopa.pn.ec.commons.model.pojo.cloudwatch.CloudWatchMetricsPublisherWrapper;
5+
import it.pagopa.pn.library.pec.configurationproperties.PnPecMetricNames;
56
import lombok.CustomLog;
6-
import org.slf4j.event.Level;
77
import org.springframework.beans.factory.annotation.Autowired;
88
import org.springframework.beans.factory.annotation.Value;
99
import org.springframework.context.annotation.Configuration;
1010
import software.amazon.awssdk.metrics.*;
11-
import software.amazon.awssdk.metrics.publishers.cloudwatch.CloudWatchMetricPublisher;
12-
import software.amazon.awssdk.metrics.publishers.cloudwatch.internal.CloudWatchMetricLogger;
1311
import software.amazon.awssdk.services.cloudwatch.CloudWatchAsyncClient;
1412

1513
import javax.annotation.PostConstruct;
1614
import java.time.Duration;
1715
import java.util.HashMap;
16+
import java.util.List;
1817
import java.util.Map;
1918

2019
/**
@@ -32,22 +31,21 @@ public class CloudWatchMetricPublisherConfiguration {
3231
private int maximumCallsPerUpload;
3332
@Value("${cloudwatch.upload-frequency-millis:#{null}}")
3433
private int uploadFrequencyMillis;
35-
@Value("${library.pec.cloudwatch.metric.response-time.mark-message-as-read}")
36-
private String markMessageAsReadResponseTimeMetric;
37-
@Value("${library.pec.cloudwatch.metric.response-time.delete-message}")
38-
private String deleteMessageResponseTimeMetric;
3934
private final CloudWatchAsyncClient cloudWatchAsyncClient;
4035
private final Map<String, CloudWatchMetricsPublisherWrapper> cloudWatchMetricPublishers = new HashMap<>();
4136
private final Map<String, SdkMetric<?>> cloudWatchSdkMetrics = new HashMap<>();
37+
private final PnPecMetricNames pnPecMetricNames;
4238

4339
/**
4440
* Instantiates a new CloudWatchMetricPublisherConfiguration.
4541
*
4642
* @param cloudWatchAsyncClient the cloud watch async client
43+
* @param pnPecMetricNames the names of the CloudWatch metrics
4744
*/
4845
@Autowired
49-
public CloudWatchMetricPublisherConfiguration(CloudWatchAsyncClient cloudWatchAsyncClient) {
46+
public CloudWatchMetricPublisherConfiguration(CloudWatchAsyncClient cloudWatchAsyncClient, PnPecMetricNames pnPecMetricNames) {
5047
this.cloudWatchAsyncClient = cloudWatchAsyncClient;
48+
this.pnPecMetricNames = pnPecMetricNames;
5149
}
5250

5351
/**
@@ -56,8 +54,8 @@ public CloudWatchMetricPublisherConfiguration(CloudWatchAsyncClient cloudWatchAs
5654
@PostConstruct
5755
private void init() {
5856
log.debug("Initializing CloudWatchMetricPublisher configurations.");
59-
initCloudWatchMetricPublishers();
6057
initCloudWatchSdkMetrics();
58+
initCloudWatchMetricPublishers();
6159
}
6260

6361
/**
@@ -98,16 +96,18 @@ public SdkMetric<?> getSdkMetricByMetricName(String metricName) {
9896
* If maximumCallsPerUpload and uploadFrequencyMillis fields are null, CloudWatchMetricPublisher class will use its default values.
9997
*/
10098
private void initCloudWatchMetricPublishers() {
101-
cloudWatchMetricPublishers.put(arubaPecNamespace, new CloudWatchMetricsPublisherWrapper(arubaPecNamespace, maximumCallsPerUpload, Duration.ofMillis(uploadFrequencyMillis), cloudWatchAsyncClient));
102-
cloudWatchMetricPublishers.put(namirialPecNamespace, new CloudWatchMetricsPublisherWrapper(namirialPecNamespace, maximumCallsPerUpload, Duration.ofMillis(uploadFrequencyMillis), cloudWatchAsyncClient));
99+
SdkMetric<String> payloadSizeRangeDimension = (SdkMetric<String>) cloudWatchSdkMetrics.get(pnPecMetricNames.getPayloadSizeRange());
100+
SdkMetric<String> messageCountRangeDimension = (SdkMetric<String>) cloudWatchSdkMetrics.get(pnPecMetricNames.getMessageCountRange());
101+
List<SdkMetric<String>> dimensions = List.of(payloadSizeRangeDimension, messageCountRangeDimension);
102+
cloudWatchMetricPublishers.put(arubaPecNamespace, new CloudWatchMetricsPublisherWrapper(arubaPecNamespace, maximumCallsPerUpload, Duration.ofMillis(uploadFrequencyMillis), cloudWatchAsyncClient, dimensions));
103+
cloudWatchMetricPublishers.put(namirialPecNamespace, new CloudWatchMetricsPublisherWrapper(namirialPecNamespace, maximumCallsPerUpload, Duration.ofMillis(uploadFrequencyMillis), cloudWatchAsyncClient, dimensions));
103104
}
104105

105106
/**
106107
* Init method to initialize SdkMetrics
107108
*/
108109
private void initCloudWatchSdkMetrics() {
109-
cloudWatchSdkMetrics.put(markMessageAsReadResponseTimeMetric, SdkMetric.create(markMessageAsReadResponseTimeMetric, Long.class, MetricLevel.INFO, MetricCategory.HTTP_CLIENT));
110-
cloudWatchSdkMetrics.put(deleteMessageResponseTimeMetric, SdkMetric.create(deleteMessageResponseTimeMetric, Long.class, MetricLevel.INFO, MetricCategory.HTTP_CLIENT));
110+
pnPecMetricNames.getAllMetrics().forEach(metricName -> cloudWatchSdkMetrics.put(metricName, SdkMetric.create(metricName, Long.class, MetricLevel.INFO, MetricCategory.HTTP_CLIENT)));
111111
}
112112

113113
}

src/main/java/it/pagopa/pn/ec/commons/configuration/http/JettyHttpClientConf.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private Request enhance(Request request, Map<String, String> mdcContextMap) {
7676
})
7777
.onRequestFailure((theRequest, throwable) -> {
7878
MDCUtils.enrichWithMDC(theRequest, mdcContextMap);
79-
log.error("Request failure : {} , {}", throwable, throwable.getMessage());
79+
log.debug("Request failure : {} , {}", throwable, throwable.getMessage());
8080
});
8181

8282

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package it.pagopa.pn.ec.commons.configurationproperties.sm;
2+
3+
import org.springframework.boot.context.properties.ConfigurationProperties;
4+
5+
@ConfigurationProperties(prefix = "pn.ec.statemachine.retry.strategy")
6+
public record StateMachineRetryStrategyProperties(Long maxAttempts, Long minBackoff) {
7+
}
8+

0 commit comments

Comments
 (0)