Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions integration-sns-to-lambda/example.js

This file was deleted.

21 changes: 21 additions & 0 deletions integration-sns-to-lambda/example.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
export const handler = async (event, context) => {
for (const record of event.Records) {
await processMessageAsync(record);
}
console.info("done");
};

async function processMessageAsync(record) {
try {
const message = JSON.stringify(record.Sns.Message);
console.log(`Processed message ${message}`);
await Promise.resolve(1); //Placeholder for actual async work
} catch (err) {
console.error("An error occurred");
throw err;
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public SQSBatchResponse handleRequest(SQSEvent sqsEvent, Context context) {
for (SQSEvent.SQSMessage message : sqsEvent.getRecords()) {
try {
//process your message
System.out.println("Processed message: " + message.getBody());
} catch (Exception e) {
//Add failed message identifier to the batchItemFailures list
batchItemFailures.add(new SQSBatchResponse.BatchItemFailure(message.getMessageId()));
Expand Down
2 changes: 1 addition & 1 deletion lambda-function-sqs-report-batch-item-failures/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def lambda_handler(event, context):

for record in event["Records"]:
try:
# process message
print(f"Processed message: {record['body']}")
except Exception as e:
batch_item_failures.append({"itemIdentifier": record['messageId']})

Expand Down