|
1 | 1 | AWSTemplateFormatVersion: "2010-09-09" |
2 | 2 | Transform: AWS::Serverless-2016-10-31 |
3 | 3 | Description: > |
4 | | - Kafka Deserialization example with Kafka Lambda ESM |
| 4 | + Large Message Handling Example using SQS and S3 offloading |
5 | 5 |
|
6 | 6 | Globals: |
7 | 7 | Function: |
8 | | - Timeout: 20 |
| 8 | + Timeout: 30 |
9 | 9 | Runtime: java11 |
10 | 10 | MemorySize: 512 |
11 | 11 | 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 |
12 | 17 |
|
13 | 18 | Resources: |
14 | | - JsonDeserializationFunction: |
15 | | - Type: AWS::Serverless::Function |
| 19 | + LargeMessageBucket: |
| 20 | + Type: AWS::S3::Bucket |
16 | 21 | 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 |
28 | 29 | 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: |
39 | 32 | Type: AWS::Serverless::Function |
40 | 33 | Properties: |
41 | 34 | 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 | + |
43 | 44 | Environment: |
44 | 45 | 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 |
49 | 47 |
|
| 48 | + Events: |
| 49 | + SQSEvent: |
| 50 | + Type: SQS |
| 51 | + Properties: |
| 52 | + Queue: !GetAtt MyLargeMessageQueue.Arn |
| 53 | + BatchSize: 1 |
50 | 54 | 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