Skip to content

Commit d8ddf08

Browse files
authored
Merge pull request #94 from higoyal01/main
Added Ruby example in Lambda-SQS with Batch failures
2 parents c8a7461 + bd31717 commit d8ddf08

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'json'
2+
3+
def lambda_handler(event:, context:)
4+
if event
5+
batch_item_failures = []
6+
sqs_batch_response = {}
7+
8+
event["Records"].each do |record|
9+
begin
10+
# process message
11+
rescue StandardError => e
12+
batch_item_failures << {"itemIdentifier" => record['messageId']}
13+
end
14+
end
15+
16+
sqs_batch_response["batchItemFailures"] = batch_item_failures
17+
return sqs_batch_response
18+
end
19+
end

integration-sqs-to-lambda-with-batch-item-handling/snippet-data.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Using an Amazon SQS trigger to invoke a Lambda function",
44
"type": "Integration",
55
"services": ["lambda", "sqs"],
6-
"languages": ["Node", "TypeScript", ".NET"],
6+
"languages": ["Node", "TypeScript", ".NET", "Ruby"],
77
"tags": [],
88
"introBox": {
99
"headline": "How it works",
@@ -52,6 +52,17 @@
5252
"language": "dotnet"
5353
}
5454
]
55+
},
56+
{
57+
"id": "Ruby",
58+
"title": "Usage Example with Ruby:",
59+
"description": "Consuming an SQS event with Lambda using Ruby with batch item handling.",
60+
"snippets": [
61+
{
62+
"snippetPath": "example.rb",
63+
"language": "ruby"
64+
}
65+
]
5566
}
5667
]
5768
}

0 commit comments

Comments
 (0)