Skip to content

Commit c658b8a

Browse files
committed
Fix Golang: lambda-function-sqs-report-batch-item-failures
1 parent 4580f59 commit c658b8a

File tree

1 file changed

+6
-3
lines changed
  • lambda-function-sqs-report-batch-item-failures

1 file changed

+6
-3
lines changed

lambda-function-sqs-report-batch-item-failures/example.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package main
44

55
import (
66
"context"
7-
"encoding/json"
87
"fmt"
98
"github.com/aws/aws-lambda-go/events"
109
"github.com/aws/aws-lambda-go/lambda"
@@ -14,8 +13,12 @@ func handler(ctx context.Context, sqsEvent events.SQSEvent) (map[string]interfac
1413
batchItemFailures := []map[string]interface{}{}
1514

1615
for _, message := range sqsEvent.Records {
17-
18-
if /* Your message processing condition here */ {
16+
if len(message.Body) > 0 {
17+
// Your message processing condition here
18+
fmt.Printf("Successfully processed message: %s\n", message.Body)
19+
} else {
20+
// Message processing failed
21+
fmt.Printf("Failed to process message %s\n", message.Body)
1922
batchItemFailures = append(batchItemFailures, map[string]interface{}{"itemIdentifier": message.MessageId})
2023
}
2124
}

0 commit comments

Comments
 (0)