Skip to content

Commit

Permalink
Merge pull request #6 from pagopa/fix-persistence-exception
Browse files Browse the repository at this point in the history
Fix blob persistence
  • Loading branch information
aomegax authored Jan 2, 2024
2 parents 3ebae3d + 5b9cb68 commit 3e8275e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>it.gov.pagopa</groupId>
<artifactId>nodoverifykototablestorage</artifactId>
<version>0.1.2</version>
<version>0.1.2-3-fix-persistence-exception</version>
<packaging>jar</packaging>

<name>Nodo Verify KO to datastore Fn</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void processNodoVerifyKOEvent (

Logger logger = context.getLogger();
logger.log(Level.INFO, () -> String.format("Persisting [%d] events...", events.size()));

String rowKey = "";
try {
if (events.size() == properties.length) {
Map<String, List<TableTransactionAction>> partitionedEvents = new HashMap<>();
Expand Down Expand Up @@ -84,7 +84,7 @@ public void processNodoVerifyKOEvent (
String insertedDateValue = dateTime.getYear() + "-" + dateTime.getMonthValue() + "-" + dateTime.getDayOfMonth();

// inserting the identification columns on event saved in Table Storage
String rowKey = generateRowKey(event, String.valueOf(timestamp));
rowKey = generateRowKey(event, String.valueOf(timestamp));
eventToBeStored.put(Constants.PARTITION_KEY_TABLESTORAGE_EVENT_FIELD, insertedDateValue);
eventToBeStored.put(Constants.ROW_KEY_TABLESTORAGE_EVENT_FIELD, rowKey);

Expand All @@ -107,7 +107,8 @@ public void processNodoVerifyKOEvent (
logger.log(Level.SEVERE, () -> String.format("[ALERT][VerifyKOToTS] AppException - Error processing events, lengths do not match: [events: %d - properties: %d]", events.size(), properties.length));
}
} catch (BlobStorageUploadException e) {
logger.log(Level.SEVERE, () -> "[ALERT][VerifyKOToTS] Persistence Exception - Could not save event body on Azure Blob Storage, error: " + e);
String finalRowKey = rowKey;
logger.log(Level.SEVERE, () -> "[ALERT][VerifyKOToTS] Persistence Exception - Could not save event body of " + finalRowKey + " on Azure Blob Storage, error: " + e);
} catch (IllegalArgumentException e) {
logger.log(Level.SEVERE, () -> "[ALERT][VerifyKOToDS] AppException - Illegal argument exception on table storage nodo-verify-ko-events msg ingestion at " + LocalDateTime.now() + " : " + e);
} catch (IllegalStateException e) {
Expand Down Expand Up @@ -191,7 +192,7 @@ private String storeBodyInBlobAndGetReference(String eventBody, String fileName)
try {
BlobClient blobClient = getBlobContainerClient().getBlobClient(fileName);
BinaryData body = BinaryData.fromStream(new ByteArrayInputStream(eventBody.getBytes(StandardCharsets.UTF_8)));
blobClient.upload(body);
blobClient.upload(body, true);
blobBodyReference = BlobBodyReference.builder()
.storageAccount(getBlobContainerClient().getAccountName())
.containerName(Constants.BLOB_NAME)
Expand Down

0 comments on commit 3e8275e

Please sign in to comment.