AWS.Messaging.Lambda 0.9.1

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package AWS.Messaging.Lambda --version 0.9.1
NuGet\Install-Package AWS.Messaging.Lambda -Version 0.9.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AWS.Messaging.Lambda" Version="0.9.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AWS.Messaging.Lambda --version 0.9.1
#r "nuget: AWS.Messaging.Lambda, 0.9.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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

nuget downloads

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 is false 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.

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.9.1 366 4/22/2024
0.9.0 693 3/26/2024
0.1.1-beta 65 3/20/2024
0.1.0-beta 178 12/8/2023