You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Processing Amazon SQS records with AWS Lambda (.NET)
2
+
3
+
This patterns shows how to process Amazon SQS messages using AWS Lambda. The AWS SAM template deploys an AWS Lambda function, an Amazon SQS queue, a dead-letter SQS queue, and the IAM permissions required to run the application. Lambda polls the SQS queue and invokes the Lambda function when new messages are available.
4
+
5
+
- To demonstrate error handling, each message has a 20% chance of random failure (remove this functionality for your own application).
6
+
- Failed messages are automatically returned to the queue for retry using `batchItemFailures`.
7
+
- After 3 failed processing attempts, messages are moved to the DLQ.
8
+
- You should implement additional functionality to process messages that are sent to the DLQ.
9
+
- Processing results are logged to Amazon CloudWatch Logs
10
+
11
+
Learn more about this pattern at Serverless Land Patterns: [serverlessland.com/patterns/sql-lambda](https://serverlessland.com/patterns/sqs-lambda-nodejs-sam)
12
+
13
+
Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the [AWS Pricing page](https://aws.amazon.com/pricing/) for details. You are responsible for any AWS costs incurred. No warranty is implied in this example.
14
+
15
+
## Requirements
16
+
17
+
*[Create an AWS account](https://portal.aws.amazon.com/gp/aws/developer/registration/index.html) if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources.
18
+
*[AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) installed and configured
*For additional information on features to help you author, build, debug, test, and deploy Lambda applications more efficiently when using Visual Studio Code, see [Introducing an enhanced local IDE experience for AWS Lambda developers](https://aws.amazon.com/blogs/compute/introducing-an-enhanced-local-ide-experience-for-aws-lambda-developers/).*
39
+
40
+
1. From the command line, use AWS SAM to deploy the AWS resources for the pattern as specified in the template.yml file:
41
+
```
42
+
sam deploy --guided
43
+
```
44
+
1. During the prompts:
45
+
* Enter a stack name
46
+
* Enter the desired AWS Region
47
+
* Allow AWS SAM CLI to create IAM roles with the required permissions.
48
+
49
+
Once you have run `sam deploy -guided` mode once and saved arguments to a configuration file `samconfig.toml`, you can use `sam deploy` in future to use these defaults.
50
+
51
+
1. Note the outputs from the AWS SAM deployment process. These contain the resource names and/or ARNs to use for testing.
"title": "Process Amazon SQS records with AWS Lambda (.NET)",
3
+
"description": "This pattern shows how to process Amazon SQS messages using AWS Lambda.",
4
+
"language": "dotnet",
5
+
"level": "200",
6
+
"framework": "SAM",
7
+
"introBox": {
8
+
"headline": "How it works",
9
+
"text": [
10
+
"The AWS SAM template deploys an AWS Lambda function, an Amazon SQS queue, a dead-letter SQS queue, and the IAM permissions required to run the application. Lambda polls the SQS queue and invokes the Lambda function when new messages are available."
"See the GitHub repo for detailed testing instructions."
39
+
]
40
+
},
41
+
"cleanup": {
42
+
"text": [
43
+
"Delete the stack: <code>sam delete</code>."
44
+
]
45
+
},
46
+
"authors": [
47
+
{
48
+
"name": "Julian Wood",
49
+
"image": "/assets/images/resources/jrwood.jpg",
50
+
"bio": "Julian Wood helps developers and builders learn about and love how serverless technologies can transform the way they build and run applications. I was an infrastructure architect and manager in global enterprises and start-ups for more than 25 years before going all in on serverless at AWS.",
0 commit comments