-
Notifications
You must be signed in to change notification settings - Fork 100
docs(examples): add SAM example for large-messages module #2319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
docs(examples): add SAM example for large-messages module #2319
Conversation
Signed-off-by: Santiago <[email protected]>
Signed-off-by: Santiago <[email protected]>
Signed-off-by: Santiago <[email protected]>
|
|
Hey @sasanchezramirez, thanks for sending this PR. Very much appreciated. I am at re:Invent this week and will review your PR next week. |
|
@sasanchezramirez Can you please update the description of this PR to match our PR template here? https://github.com/aws-powertools/powertools-lambda-java/blob/main/.github/PULL_REQUEST_TEMPLATE.md Especially, make sure that the disclaimer is included (bottom section). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @sasanchezramirez,
thanks for sending this PR. It is a great start! Beyond the comments below, I would like to provide a full end-to-end example here. Currently, we are missing the producer side using the SQS extended lib client.
My suggestion is this:
- Create a new
tools/folder - In this folder provide a small tool that can be executed locally using the maven exec plugin
- This should contain a small Java script that uses the SQS extended client to send a large payload loaded from e.g. a JSON file to the Lambda.
- Add instructions on how to run this producer tool to the README.md
This will show users not only how to consume messages but gives them a starting point with a consumer and a producer function.
Note: We have such a producer tool already for our Kafka example here: https://github.com/aws-powertools/powertools-lambda-java/tree/main/examples/powertools-examples-kafka/tools
| @@ -0,0 +1,27 @@ | |||
| # Powertools for AWS Lambda (Java) - Large Messages Example | |||
|
|
|||
| This project contains an example of a Lambda function using the **Large Messages** module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/large_messages/). | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| This project contains an example of a Lambda function using the **Large Messages** module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.powertools.aws.dev/lambda-java/utilities/large_messages/). | |
| This project contains an example of a Lambda function using the **Large Messages** module of Powertools for AWS Lambda (Java). For more information on this module, please refer to the [documentation](https://docs.aws.amazon.com/powertools/java/latest/utilities/large_messages/). |
| <properties> | ||
| <maven.compiler.source>11</maven.compiler.source> | ||
| <maven.compiler.target>11</maven.compiler.target> | ||
| <log4j.version>2.21.1</log4j.version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This maven property is not used anywhere.
| */ | ||
| public final class App implements RequestHandler<SQSEvent, String> { | ||
|
|
||
| private static final Logger LOG = LogManager.getLogger(App.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following our documentation, let's use SLF4J here instead of direct calls to Log4j2. Also, we forgot to add the @Logging annotation to the handleRequest method.
https://docs.aws.amazon.com/powertools/java/latest/core/logging/
| <maven.compiler.target>11</maven.compiler.target> | ||
| <log4j.version>2.21.1</log4j.version> | ||
| <aspectj.version>1.9.21</aspectj.version> | ||
| <amazon-sqs-java-extended-client-lib.version>2.1.1</amazon-sqs-java-extended-client-lib.version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not used anywhere.
| <dependency> | ||
| <groupId>com.amazonaws</groupId> | ||
| <artifactId>amazon-sqs-java-extended-client-lib</artifactId> | ||
| <version>${amazon-sqs-java-extended-client-lib.version}</version> | ||
| </dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use this dependency in the consuming Lambda.
| ```bash | ||
| aws cloudformation describe-stacks --stack-name LargeMessageExample --query "Stacks[0].Outputs[?OutputKey=='QueueURL'].OutputValue" --output text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not forgot to close the markdown block again.



Summary
This PR introduces a comprehensive SAM example for the
powertools-large-messagesmodule. It demonstrates how to use the functional interface approach (LargeMessages.processLargeMessage) to handle SQS messages with offloaded S3 payloads, following the request in the linked issue.Changes
powertools-examples-large-messagesunderexamples/.template.yamlconfiguring S3, SQS, and Lambda with correct IAM permissions (S3CrudPolicy).App.javademonstratingLargeMessages.processLargeMessage()usage (functional API).pom.xmlwith the latest SQS Extended Client dependency.README.mdwith deployment and testing instructions.log4j2.xmlresource for proper logging output.Issue number: Closes #1353
Type of change
Checklist