Skip to content

Conversation

@sasanchezramirez
Copy link

Summary

This PR introduces a comprehensive SAM example for the powertools-large-messages module. 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

  • Created new module powertools-examples-large-messages under examples/.
  • Added template.yaml configuring S3, SQS, and Lambda with correct IAM permissions (S3CrudPolicy).
  • Implemented App.java demonstrating LargeMessages.processLargeMessage() usage (functional API).
  • Configured pom.xml with the latest SQS Extended Client dependency.
  • Added README.md with deployment and testing instructions.
  • Added log4j2.xml resource for proper logging output.

Issue number: Closes #1353

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Documentation update
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • My code follows the code style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • Changes generate no new warnings

@sonarqubecloud
Copy link

@phipag
Copy link
Contributor

phipag commented Dec 1, 2025

Hey @sasanchezramirez,

thanks for sending this PR. Very much appreciated.

I am at re:Invent this week and will review your PR next week.

@phipag
Copy link
Contributor

phipag commented Dec 9, 2025

@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).

Copy link
Contributor

@phipag phipag left a 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/).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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>
Copy link
Contributor

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);
Copy link
Contributor

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>
Copy link
Contributor

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.

Comment on lines +25 to +29
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>amazon-sqs-java-extended-client-lib</artifactId>
<version>${amazon-sqs-java-extended-client-lib.version}</version>
</dependency>
Copy link
Contributor

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.

Comment on lines +18 to +19
```bash
aws cloudformation describe-stacks --stack-name LargeMessageExample --query "Stacks[0].Outputs[?OutputKey=='QueueURL'].OutputValue" --output text
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs: Example coverage - powertools-large-messages missing

2 participants