Skip to content

Commit 9b2e860

Browse files
docs(examples): add SAM template with S3 and SQS resources
Signed-off-by: Santiago <sasanchezramirez@gmail.com>
1 parent bba1a8b commit 9b2e860

File tree

3 files changed

+50
-55
lines changed

3 files changed

+50
-55
lines changed

examples/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<module>powertools-examples-batch</module>
4646
<module>powertools-examples-validation</module>
4747
<module>powertools-examples-cloudformation</module>
48+
<module>powertools-examples-large-messages</module>
4849
</modules>
4950

5051
<build>

examples/powertools-examples-large-messages/pom.xml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>software.amazon.lambda.examples</groupId>
55
<version>2.8.0</version>
6-
<artifactId>powertools-examples-kafka</artifactId>
6+
<artifactId>powertools-examples-large-messages</artifactId>
77
<packaging>jar</packaging>
8-
<name>Powertools for AWS Lambda (Java) - Examples - Kafka</name>
8+
<name>Powertools for AWS Lambda (Java) - Examples - Large Messages</name>
99

1010
<properties>
1111
<maven.compiler.source>11</maven.compiler.source>
@@ -18,23 +18,13 @@
1818
<dependencies>
1919
<dependency>
2020
<groupId>software.amazon.lambda</groupId>
21-
<artifactId>powertools-kafka</artifactId>
21+
<artifactId>powertools-large-messages</artifactId>
2222
<version>${project.version}</version>
2323
</dependency>
2424
<dependency>
25-
<groupId>org.apache.kafka</groupId>
26-
<artifactId>kafka-clients</artifactId>
27-
<version>4.1.1</version> <!-- Supports >= 3.0.0 -->
28-
</dependency>
29-
<dependency>
30-
<groupId>org.apache.avro</groupId>
31-
<artifactId>avro</artifactId>
32-
<version>${avro.version}</version>
33-
</dependency>
34-
<dependency>
35-
<groupId>com.google.protobuf</groupId>
36-
<artifactId>protobuf-java</artifactId>
37-
<version>${protobuf.version}</version>
25+
<groupId>com.amazonaws</groupId>
26+
<artifactId>amazon-sqs-java-extended-client-lib</artifactId>
27+
<version>2.1.1</version>
3828
</dependency>
3929

4030
<!-- Basic logging setup -->
Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,63 @@
11
AWSTemplateFormatVersion: "2010-09-09"
22
Transform: AWS::Serverless-2016-10-31
33
Description: >
4-
Kafka Deserialization example with Kafka Lambda ESM
4+
Large Message Handling Example using SQS and S3 offloading
55
66
Globals:
77
Function:
8-
Timeout: 20
8+
Timeout: 30
99
Runtime: java11
1010
MemorySize: 512
1111
Tracing: Active
12+
Environment:
13+
Variables:
14+
JAVA_TOOL_OPTIONS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
15+
POWERTOOLS_LOG_LEVEL: INFO
16+
POWERTOOLS_SERVICE_NAME: LargeMessageExample
1217

1318
Resources:
14-
JsonDeserializationFunction:
15-
Type: AWS::Serverless::Function
19+
LargeMessageBucket:
20+
Type: AWS::S3::Bucket
1621
Properties:
17-
CodeUri: .
18-
Handler: org.demo.kafka.JsonDeserializationFunction::handleRequest
19-
Environment:
20-
Variables:
21-
JAVA_TOOL_OPTIONS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
22-
POWERTOOLS_LOG_LEVEL: DEBUG
23-
POWERTOOLS_SERVICE_NAME: JsonDeserialization
24-
POWERTOOLS_METRICS_NAMESPACE: JsonDeserializationFunction
25-
26-
AvroDeserializationFunction:
27-
Type: AWS::Serverless::Function
22+
LifecycleConfiguration:
23+
Rules:
24+
- Id: DeleteOldMessages
25+
Status: Enabled
26+
ExpirationInDays: 1
27+
MyLargeMessageQueue:
28+
Type: AWS::SQS::Queue
2829
Properties:
29-
CodeUri: .
30-
Handler: org.demo.kafka.AvroDeserializationFunction::handleRequest
31-
Environment:
32-
Variables:
33-
JAVA_TOOL_OPTIONS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
34-
POWERTOOLS_LOG_LEVEL: DEBUG
35-
POWERTOOLS_SERVICE_NAME: AvroDeserialization
36-
POWERTOOLS_METRICS_NAMESPACE: AvroDeserializationFunction
37-
38-
ProtobufDeserializationFunction:
30+
VisibilityTimeout: 30
31+
LargeMessageProcessingFunction:
3932
Type: AWS::Serverless::Function
4033
Properties:
4134
CodeUri: .
42-
Handler: org.demo.kafka.ProtobufDeserializationFunction::handleRequest
35+
# IMPORTANTE: Asegúrate que esto coincida con tu paquete y clase Java
36+
Handler: helloworld.App::handleRequest
37+
38+
Policies:
39+
- S3CrudPolicy:
40+
BucketName: !Ref LargeMessageBucket
41+
- SQSPollerPolicy:
42+
QueueName: !GetAtt MyLargeMessageQueue.QueueName
43+
4344
Environment:
4445
Variables:
45-
JAVA_TOOL_OPTIONS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
46-
POWERTOOLS_LOG_LEVEL: DEBUG
47-
POWERTOOLS_SERVICE_NAME: ProtobufDeserialization
48-
POWERTOOLS_METRICS_NAMESPACE: ProtobufDeserializationFunction
46+
POWERTOOLS_LARGE_MESSAGES_BUCKET: !Ref LargeMessageBucket
4947

48+
Events:
49+
SQSEvent:
50+
Type: SQS
51+
Properties:
52+
Queue: !GetAtt MyLargeMessageQueue.Arn
53+
BatchSize: 1
5054
Outputs:
51-
JsonFunction:
52-
Description: "Kafka JSON Lambda Function ARN"
53-
Value: !GetAtt JsonDeserializationFunction.Arn
54-
AvroFunction:
55-
Description: "Kafka Avro Lambda Function ARN"
56-
Value: !GetAtt AvroDeserializationFunction.Arn
57-
ProtobufFunction:
58-
Description: "Kafka Protobuf Lambda Function ARN"
59-
Value: !GetAtt ProtobufDeserializationFunction.Arn
55+
LargeMessageBucketName:
56+
Description: "S3 Bucket for large payloads"
57+
Value: !Ref LargeMessageBucket
58+
QueueURL:
59+
Description: "SQS Queue URL"
60+
Value: !Ref MyLargeMessageQueue
61+
FunctionArn:
62+
Description: "Lambda Function ARN"
63+
Value: !GetAtt LargeMessageProcessingFunction.Arn

0 commit comments

Comments
 (0)