Skip to content

Commit 57bdd77

Browse files
committed
logs and doc
1 parent 78da8a7 commit 57bdd77

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

docs/utilities/large_messages.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,8 @@ using the `deleteObject(bucket, key)` API. You can disable the deletion of S3 ob
334334

335335
!!! tip "Use together with idempotency module"
336336
This utility also works together with the idempotency module (`powertools-idempotency`).
337-
You can add both the `@LargeMessage` and `@Idempotent` annotations to the same method.
338-
The `@Idempotent` takes precedence over the `@LargeMessage` annotation.
337+
You can add both the `@LargeMessage` and `@Idempotent` annotations, in any order, to the same method.
338+
The `@Idempotent` takes precedence over the `@LargeMessage` annotation.
339339
It means Idempotency module will use the initial raw message (containing the S3 pointer) and not the large message.
340340
Using the large message would end up with potential issues when inserting the data in DynamoDB, where items
341341
are limited to 400 KB (while large messages can be up to 2 GB).

powertools-large-messages/src/main/java/software/amazon/lambda/powertools/largemessages/internal/LargeMessageProcessor.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import static java.lang.String.format;
1818

19+
import java.nio.charset.StandardCharsets;
1920
import org.aspectj.lang.ProceedingJoinPoint;
2021
import org.slf4j.Logger;
2122
import org.slf4j.LoggerFactory;
@@ -57,19 +58,26 @@ public Object process(ProceedingJoinPoint pjp, boolean deleteS3Object) throws Th
5758
// legacy attribute (sqs only)
5859
payloadPointer = payloadPointer.replace("com.amazon.sqs.javamessaging.MessageS3Pointer", "software.amazon.payloadoffloading.PayloadS3Pointer");
5960

60-
LOG.info("Large message [{}]: retrieving content from S3", getMessageId(message));
61+
if (LOG.isInfoEnabled()) {
62+
LOG.info("Large message [{}]: retrieving content from S3", getMessageId(message));
63+
}
6164

6265
String s3ObjectContent = getS3ObjectContent(payloadPointer);
6366

64-
LOG.debug("Large message [{}]: {}", getMessageId(message), s3ObjectContent);
67+
if (LOG.isDebugEnabled()) {
68+
LOG.debug("Large message [{}] retrieved in S3 [{}]: {}KB", getMessageId(message), payloadPointer,
69+
s3ObjectContent.getBytes(StandardCharsets.UTF_8).length / 1024);
70+
}
6571

6672
updateMessageContent(message, s3ObjectContent);
6773
removeLargeMessageAttributes(message);
6874

6975
Object response = pjp.proceed(proceedArgs);
7076

7177
if (deleteS3Object) {
72-
LOG.info("Large message [{}]: deleting object from S3", getMessageId(message));
78+
if (LOG.isInfoEnabled()) {
79+
LOG.info("Large message [{}]: deleting object from S3", getMessageId(message));
80+
}
7381
deleteS3Object(payloadPointer);
7482
}
7583

@@ -127,7 +135,6 @@ private void deleteS3Object(String payloadPointer) {
127135
try {
128136
payloadStore.deleteOriginalPayload(payloadPointer);
129137
} catch (SdkException e) {
130-
// TODO: should we actually throw an exception if deletion failed ?
131138
throw new LargeMessageProcessingException(format("Failed deleting S3 record [%s]", payloadPointer), e);
132139
}
133140
}

0 commit comments

Comments
 (0)