From b008a39c8cd0bf976ca51290c0394d37aab7b739 Mon Sep 17 00:00:00 2001 From: Himanshu Goyal Date: Tue, 14 Nov 2023 11:48:41 +0530 Subject: [PATCH 1/4] Added ruby example --- .../example.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 integration-sqs-to-lambda-with-batch-item-handling/example.rb diff --git a/integration-sqs-to-lambda-with-batch-item-handling/example.rb b/integration-sqs-to-lambda-with-batch-item-handling/example.rb new file mode 100644 index 0000000..e603c3d --- /dev/null +++ b/integration-sqs-to-lambda-with-batch-item-handling/example.rb @@ -0,0 +1,19 @@ +require 'json' + +def lambda_handler(event:, context:) + if event + batch_item_failures = [] + sqs_batch_response = {} + + event["Records"].each do |record| + begin + # process message + rescue StandardError => e + batch_item_failures << {"itemIdentifier" => record['messageId']} + end + end + + sqs_batch_response["batchItemFailures"] = batch_item_failures + return sqs_batch_response + end +end From f24ab7b267692aac2cef181c93874f67fff2aad7 Mon Sep 17 00:00:00 2001 From: Himanshu Goyal Date: Tue, 14 Nov 2023 11:52:46 +0530 Subject: [PATCH 2/4] Update snippet-data.json --- .../snippet-data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-sqs-to-lambda-with-batch-item-handling/snippet-data.json b/integration-sqs-to-lambda-with-batch-item-handling/snippet-data.json index b745161..02d9ac1 100644 --- a/integration-sqs-to-lambda-with-batch-item-handling/snippet-data.json +++ b/integration-sqs-to-lambda-with-batch-item-handling/snippet-data.json @@ -2,7 +2,7 @@ "title": "Amazon SQS trigger to invoke a Lambda function", "description": "Using an Amazon SQS trigger to invoke a Lambda function", "type": "Integration", - "services": ["lambda", "sqs"], + "services": ["lambda", "sqs", "ruby"], "languages": ["Node", "TypeScript", ".NET"], "tags": [], "introBox": { From 23bcdb71ae41cbb81b2735d4363f7251c56e86c5 Mon Sep 17 00:00:00 2001 From: Himanshu Goyal Date: Tue, 14 Nov 2023 17:01:04 +0530 Subject: [PATCH 3/4] Update snippet-data.json --- .../snippet-data.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-sqs-to-lambda-with-batch-item-handling/snippet-data.json b/integration-sqs-to-lambda-with-batch-item-handling/snippet-data.json index 02d9ac1..9bc688f 100644 --- a/integration-sqs-to-lambda-with-batch-item-handling/snippet-data.json +++ b/integration-sqs-to-lambda-with-batch-item-handling/snippet-data.json @@ -2,8 +2,8 @@ "title": "Amazon SQS trigger to invoke a Lambda function", "description": "Using an Amazon SQS trigger to invoke a Lambda function", "type": "Integration", - "services": ["lambda", "sqs", "ruby"], - "languages": ["Node", "TypeScript", ".NET"], + "services": ["lambda", "sqs"], + "languages": ["Node", "TypeScript", ".NET", "Ruby"], "tags": [], "introBox": { "headline": "How it works", From bd317179d548c786007c19c1d3d9b1e158a68b8b Mon Sep 17 00:00:00 2001 From: Himanshu Goyal Date: Fri, 17 Nov 2023 10:28:15 +0530 Subject: [PATCH 4/4] Update snippet-data.json --- .../snippet-data.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/integration-sqs-to-lambda-with-batch-item-handling/snippet-data.json b/integration-sqs-to-lambda-with-batch-item-handling/snippet-data.json index 9bc688f..12b04b7 100644 --- a/integration-sqs-to-lambda-with-batch-item-handling/snippet-data.json +++ b/integration-sqs-to-lambda-with-batch-item-handling/snippet-data.json @@ -52,6 +52,17 @@ "language": "dotnet" } ] + }, + { + "id": "Ruby", + "title": "Usage Example with Ruby:", + "description": "Consuming an SQS event with Lambda using Ruby with batch item handling.", + "snippets": [ + { + "snippetPath": "example.rb", + "language": "ruby" + } + ] } ] }