AWS.Messaging.Lambda
0.9.1
Prefix Reserved
See the version list below for details.
dotnet add package AWS.Messaging.Lambda --version 0.9.1
NuGet\Install-Package AWS.Messaging.Lambda -Version 0.9.1
<PackageReference Include="AWS.Messaging.Lambda" Version="0.9.1" />
paket add AWS.Messaging.Lambda --version 0.9.1
#r "nuget: AWS.Messaging.Lambda, 0.9.1"
// Install AWS.Messaging.Lambda as a Cake Addin #addin nuget:?package=AWS.Messaging.Lambda&version=0.9.1 // Install AWS.Messaging.Lambda as a Cake Tool #tool nuget:?package=AWS.Messaging.Lambda&version=0.9.1
AWS Lambda plugin for AWS Message Processing Framework for .NET
Notice: This library is in developer preview. It provides early access to upcoming features in the AWS Message Processing Framework for .NET. Any releases prior to 1.0.0 might include breaking changes.
This package is a plugin for the AWS Message Processing Framework for .NET that allows a .NET Lambda function to handle messages that were published by the framework.
In AWS Lambda, the service takes care of reading the messages from the SQS queue and invoking your Lambda functions with the message events. This plugin allows you to feed the incoming Lambda event to message processing framework so it can dispatch the messages to the IMessageHandler
.
Example
To get started, add the AWS.Messaging.Lambda
NuGet package to your project:
dotnet add package AWS.Messaging.Lambda
The example shown below uses the .NET Amazon Lambda Annotations framework, which makes it easy to set up .NET's dependency injection.
In the Startup
class, add a call to AddAWSMessageBus
to configure the AWS Message Processing Framework with the IMessageHandler
for each message type you expect the Lambda function to process. To inject the required services for using Lambda with the framework, add a call to AddLambdaMessageProcessor
.
Publishers can also be configured if you expect the Lambda function to publish messages.
[LambdaStartup]
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddAWSMessageBus(builder =>
{
builder.AddMessageHandler<OrderHandler, OrderInfo>();
builder.AddLambdaMessageProcessor(options =>
{
options.MaxNumberOfConcurrentMessages = 4;
});
});
}
}
In the Lambda function itself you need to inject the ILambdaMessaging
service. This service provides the entry point for the Lambda function
to pass in the SQSEvent
sent in by the Lambda service. If your Lambda function is configured for partial failure response use the
ProcessLambdaEventWithBatchResponseAsync
and return the instance of SQSBatchResponse
. If partial failure response is not enabled
use the ProcessLambdaEventAsync
method.
public class Function
{
[LambdaFunction(Policies = "AWSLambdaSQSQueueExecutionRole")]
public async Task<SQSBatchResponse> FunctionHandler([FromServices] ILambdaMessaging messaging, SQSEvent evnt, ILambdaContext context)
{
return await messaging.ProcessLambdaEventWithBatchResponseAsync(evnt, context);
}
}
Options
When calling AddLambdaMessageProcessor
the following options are available to configure the framework.
- MaxNumberOfConcurrentMessages: The max number of messages the Lambda function will process at the same time.
The default value is
10
. - DeleteMessagesWhenCompleted: When not using partial response failure with Lambda if this is set to
true
then after each message has been successfully processed the framework will delete the message. The default value isfalse
which means the Lambda service will delete all of the messages in the Lambda event if the function invocation was successful. If the function is configured for partial response failure this property is ignored.
Useful Links
- AWS Message Processing Framework for .NET Design Document
- Sample Applications - contains sample applications of a publisher service, long-running subscriber service, Lambda function handlers, and using Polly to override the framework's built-in backoff logic.
- Developer Guide
- API Reference
- Introducing the AWS Message Processing Framework for .NET (Preview) Blog Post - walks through creating simple applications to send and receive SQS messages.
Security
See CONTRIBUTING for more information.
License
This project is licensed under the Apache-2.0 License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Amazon.Lambda.Core (>= 2.2.0)
- Amazon.Lambda.SQSEvents (>= 2.2.0)
- AWS.Messaging (>= 0.9.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on AWS.Messaging.Lambda:
Repository | Stars |
---|---|
aws/aws-lambda-dotnet
Libraries, samples and tools to help .NET Core developers develop AWS Lambda functions.
|
Version | Downloads | Last updated |
---|---|---|
0.10.0 | 1,126 | 8/2/2024 |
0.9.1 | 1,584 | 4/22/2024 |
0.9.0 | 4,382 | 3/26/2024 |
0.1.1-beta | 83 | 3/20/2024 |
0.1.0-beta | 195 | 12/8/2023 |