Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync dev to v4 #200

Merged
merged 7 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .autover/changes/01370ae5-3537-4723-80b3-ee82e79e80b9.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"Projects": [
{
"Name": "AWS.Messaging",
"Type": "Patch",
"ChangelogMessages": [
"Update error message for handling scenario where subscriber mapping is not valid."
]
}
]
}
44 changes: 23 additions & 21 deletions .github/workflows/doc-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,33 @@ permissions:
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
publish-docs:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Dotnet Setup
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # pinning V4
with:
dotnet-version: 8.x

- run: dotnet tool update -g docfx --version 2.74.0
- run: docfx docs/docfx.json

- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
# Upload entire repository
path: 'docs/_site'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pinning V4
- name: Dotnet Setup
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # pinning V4
with:
dotnet-version: 8.x

- run: dotnet tool update -g docfx --version 2.78.3
- run: docfx docs/docfx.json

- name: Setup Pages
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # pinning V5
- name: Upload artifact
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # pinning V3
with:
# Upload entire repository
path: "docs/_site"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # pinning V4


5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Release 2025-03-12

### AWS.Messaging (0.9.5)
* Update error message for handling scenario where subscriber mapping is not valid.

## Release 2025-02-20

### AWS.Messaging (0.9.4)
Expand Down
20 changes: 20 additions & 0 deletions sampleapps/LambdaMessaging/HandlerSampleRequest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"Records": [
{
"messageId": "19dd0b57-b21e-4ac1-bd88-01bbb068cb78",
"receiptHandle": "MessageReceiptHandle",
"body": "{\"id\":\"d9b4bfc7-9398-44aa-8049-85c07490fb35\",\"source\":\"/AWSLambda/FunctionName\",\"specversion\":\"1.0\",\"type\":\"chatMessage\",\"time\":\"2024-03-22T21:01:03.5484607+00:00\",\"data\":\"{\\u0022MessageDescription\\u0022:\\u0022Testing!!!\\u0022}\"}",
"attributes": {
"ApproximateReceiveCount": "1",
"SentTimestamp": "1523232000000",
"SenderId": "123456789012",
"ApproximateFirstReceiveTimestamp": "1523232000001"
},
"messageAttributes": {},
"md5OfBody": "7b270e59b47ff90a553787216d55d91d",
"eventSource": "aws:sqs",
"eventSourceARN": "arn:{partition}:sqs:{region}:123456789012:MyQueue",
"awsRegion": "{region}"
}
]
}
9 changes: 3 additions & 6 deletions sampleapps/LambdaMessaging/LambdaMessaging.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@
<Nullable>enable</Nullable>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AWSProjectType>Lambda</AWSProjectType>
<!-- This property makes the build directory similar to a publish directory and helps the AWS .NET Lambda Mock Test Tool find project dependencies. -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<!-- Generate ready to run images during publishing to improve cold start time. -->
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="2.5.1" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.4" />
<PackageReference Include="Amazon.Lambda.SQSEvents" Version="2.2.0" />
<PackageReference Include="Amazon.Lambda.Annotations" Version="1.7.0" />
<PackageReference Include="Amazon.Lambda.Logging.AspNetCore" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.*" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.0" />
<PackageReference Include="Amazon.Lambda.Logging.AspNetCore" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\AWS.Messaging.Lambda\AWS.Messaging.Lambda.csproj" />
Expand Down
13 changes: 8 additions & 5 deletions sampleapps/LambdaMessaging/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"profiles": {
"Mock Lambda Test Tool": {
"commandName": "Executable",
"commandLineArgs": "--port 5050",
"Default": {
"workingDirectory": ".\\bin\\$(Configuration)\\net8.0",
"executablePath": "%USERPROFILE%\\.dotnet\\tools\\dotnet-lambda-test-tool-8.0.exe"
"commandName": "Executable",
"commandLineArgs": "exec --depsfile ./LambdaMessaging.deps.json --runtimeconfig ./LambdaMessaging.runtimeconfig.json %USERPROFILE%/.dotnet/tools/.store/amazon.lambda.testtool/${VERSION}/amazon.lambda.testtool/${VERSION}/content/Amazon.Lambda.RuntimeSupport/net8.0/Amazon.Lambda.RuntimeSupport.dll LambdaMessaging::LambdaMessaging.Function_FunctionHandler_Generated::FunctionHandler",
"executablePath": "dotnet",
"environmentVariables": {
"AWS_LAMBDA_RUNTIME_API": "localhost:5050/MyFunction"
}
}
}
}
}
79 changes: 79 additions & 0 deletions sampleapps/LambdaMessaging/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Lambda Messaging Sample Application

This sample application demonstrates how to use AWS Lambda with the AWS Message Processing Framework for .NET to process messages from SQS queues.

## Overview

This sample shows how to:
- Configure a Lambda function to process messages from SQS
- Use dependency injection with Lambda Annotations
- Handle message batch processing
- Implement partial batch failure responses
- Set up message handlers for specific message types

## Prerequisites

- .NET 8.0 or later


## Project Structure

```
LambdaMessaging/
├── Function.cs # Lambda function handler
├── Startup.cs # DI and service configuration
├── ChatMessage.cs # Message type definition
├── ChatMessageHandler.cs # Message handler implementation
├── LambdaMessaging.csproj # Project file
```


## Getting Started

In order to test the lambda function locally with the messaging processing framework, it requires installing the Lambda Test Tool https://github.com/aws/aws-lambda-dotnet/blob/master/Tools/LambdaTestTool-v2 first.

1. Build the project

```
dotnet build
```

2Install the AWS Lambda Test Tool:
```bash
dotnet tool install -g amazon.lambda.testtool
```

3. Start the Lambda Test Tool:

```bash
dotnet lambda-test-tool start --lambda-emulator-port 5050
```

4. Get the test tool version:

```
dotnet lambda-test-tool info
```

5. Run the `LambdaMessaging` project.

There are 2 ways to run it
1. Visual studio (easiest way).
1a. Update `Properties/launchSettings.json` and replace `${VERSIOMN} with the actual test tool version.
2. Via command line

```
cd bin\Debug\net8.0
$env:AWS_LAMBDA_RUNTIME_API = "localhost:5050/MyFunction"
$env:VERSION = "0.9.1" // Use the version returned from dotnet lambda-test-tool info

dotnet exec --depsfile ./LambdaMessaging.deps.json --runtimeconfig ./LambdaMessaging.runtimeconfig.json "$env:USERPROFILE\.dotnet\tools\.store\amazon.lambda.testtool\$env:VERSION\amazon.lambda.testtool\$env:VERSION\content\Amazon.Lambda.RuntimeSupport\net8.0\Amazon.Lambda.RuntimeSupport.dll" LambdaMessaging::LambdaMessaging.Function_FunctionHandler_Generated::FunctionHandler


```

6. You should now see the `MyFunction` appear in the test tools function list drop down in the top right corner. Select `MyFunction`.

7. We have provided a `HandlerSampleRequest.json` file to be used to test this function. Copy and paste this json into the test tools input window and then hit the "invoke button".

8. You should see in the console window that the `ChatMessageHandler` successfully processed the message. There should be a log statement saying `Message Description: Testing!!!`.
18 changes: 11 additions & 7 deletions sampleapps/LambdaMessaging/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
using Amazon.Lambda.Annotations;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace LambdaMessaging;

[LambdaStartup]
public class Startup
{
public void ConfigureServices(IServiceCollection services)
public HostApplicationBuilder ConfigureHostBuilder()
{
services.AddLogging(builder =>
var builder = new HostApplicationBuilder();
builder.Services.AddLogging(b =>
{
builder.SetMinimumLevel(LogLevel.Trace);
builder.AddLambdaLogger();
b.SetMinimumLevel(LogLevel.Trace);
b.AddLambdaLogger();
});
services.AddAWSMessageBus(builder =>
builder.Services.AddAWSMessageBus(b =>
{
builder.AddMessageHandler<ChatMessageHandler, ChatMessage>("chatMessage");
b.AddMessageHandler<ChatMessageHandler, ChatMessage>("chatMessage");

builder.AddLambdaMessageProcessor(options =>
b.AddLambdaMessageProcessor(options =>
{
options.MaxNumberOfConcurrentMessages = 2;
});
});

return builder;
}
}
4 changes: 2 additions & 2 deletions sampleapps/PollyIntegration/PollyIntegration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.*" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.*" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.6.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.6.0" />
<PackageReference Include="Polly.Core" Version="8.1.0" />
Expand Down
Loading
Loading