diff --git a/samples/aws/lambda-sqs/SQSLambda_3/RegularEndpoint/InputLoopService.cs b/samples/aws/lambda-sqs/SQSLambda_3/RegularEndpoint/InputLoopService.cs deleted file mode 100644 index 5b6bcf24d8e..00000000000 --- a/samples/aws/lambda-sqs/SQSLambda_3/RegularEndpoint/InputLoopService.cs +++ /dev/null @@ -1,30 +0,0 @@ - -using System; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Extensions.Hosting; -using NServiceBus; -public class InputLoopService(IMessageSession messageSession) : BackgroundService -{ - protected override async Task ExecuteAsync(CancellationToken stoppingToken) - { - - Console.WriteLine("Press [ENTER] to send a message to the serverless endpoint queue."); - Console.WriteLine("Press [Esc] to exit."); - - while (true) - { - var key = Console.ReadKey(); - Console.WriteLine(); - switch (key.Key) - { - case ConsoleKey.Enter: - await messageSession.Send("ServerlessEndpoint", new TriggerMessage()); - Console.WriteLine("Message sent to the serverless endpoint queue."); - break; - case ConsoleKey.Escape: - return; - } - } - } -} diff --git a/samples/aws/lambda-sqs/SQSLambda_3/RegularEndpoint/Program.cs b/samples/aws/lambda-sqs/SQSLambda_3/RegularEndpoint/Program.cs index 9706757ae49..e3f49608ead 100644 --- a/samples/aws/lambda-sqs/SQSLambda_3/RegularEndpoint/Program.cs +++ b/samples/aws/lambda-sqs/SQSLambda_3/RegularEndpoint/Program.cs @@ -1,4 +1,6 @@ using System; +using System.Threading; +using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using NServiceBus; @@ -6,17 +8,47 @@ Console.Title = "RegularEndpoint"; var builder = Host.CreateApplicationBuilder(args); -builder.Services.AddHostedService(); var endpointConfiguration = new EndpointConfiguration("RegularEndpoint"); - endpointConfiguration.UseSerialization(); endpointConfiguration.UseTransport(); - Console.WriteLine("Press any key, the application is starting"); Console.ReadKey(); Console.WriteLine("Starting..."); builder.UseNServiceBus(endpointConfiguration); -await builder.Build().RunAsync(); + +var host = builder.Build(); +await host.StartAsync(); + +// Get the required services +var messageSession = host.Services.GetRequiredService(); +// Register a cancellation token to gracefully handle application shutdown +var ct = host.Services.GetRequiredService().ApplicationStopping; + +Console.WriteLine("Press [ENTER] to send a message to the serverless endpoint queue."); +Console.WriteLine("Press Ctrl+C to shut down."); + +// Wait for user input to publish messages +while (!ct.IsCancellationRequested) +{ + if (!Console.KeyAvailable) + { + // If no key is pressed, wait for a short time before checking again + await Task.Delay(100, CancellationToken.None); + continue; + } + + var key = Console.ReadKey(); + Console.WriteLine(); + + if (key.Key == ConsoleKey.Enter) + { + await messageSession.Send("ServerlessEndpoint", new TriggerMessage()); + Console.WriteLine("Message sent to the serverless endpoint queue."); + } +} + +// Wait for the host to stop gracefully +await host.StopAsync(); \ No newline at end of file diff --git a/samples/aws/lambda-sqs/SQSLambda_3/RegularEndpoint/ResponseMessageHandler.cs b/samples/aws/lambda-sqs/SQSLambda_3/RegularEndpoint/ResponseMessageHandler.cs index d5ff03a04e9..073634b9705 100644 --- a/samples/aws/lambda-sqs/SQSLambda_3/RegularEndpoint/ResponseMessageHandler.cs +++ b/samples/aws/lambda-sqs/SQSLambda_3/RegularEndpoint/ResponseMessageHandler.cs @@ -4,7 +4,6 @@ public class ResponseMessageHandler(ILogger logger) : IHandleMessages { - public Task Handle(ResponseMessage message, IMessageHandlerContext context) { logger.LogInformation("Handling {MessageType} in RegularEndpoint", nameof(ResponseMessage)); diff --git a/samples/aws/lambda-sqs/SQSLambda_3/ServerlessEndpoint/TriggerMessageHandler.cs b/samples/aws/lambda-sqs/SQSLambda_3/ServerlessEndpoint/TriggerMessageHandler.cs index 4d28e9c9115..7fe11f12104 100644 --- a/samples/aws/lambda-sqs/SQSLambda_3/ServerlessEndpoint/TriggerMessageHandler.cs +++ b/samples/aws/lambda-sqs/SQSLambda_3/ServerlessEndpoint/TriggerMessageHandler.cs @@ -1,13 +1,15 @@ using System.Threading.Tasks; -using Microsoft.Extensions.Logging; using NServiceBus; +using NServiceBus.Logging; #region TriggerMessageHandler -public class TriggerMessageHandler(ILogger logger) : IHandleMessages +public class TriggerMessageHandler : IHandleMessages { + static readonly ILog Log = LogManager.GetLogger(); + public async Task Handle(TriggerMessage message, IMessageHandlerContext context) { - logger.LogInformation("Handling {MessageType} in ServerlessEndpoint.", nameof(TriggerMessage)); + Log.Info($"Handling {nameof(TriggerMessage)} in ServerlessEndpoint."); await context.Send(new ResponseMessage()); } } diff --git a/samples/aws/lambda-sqs/SQSLambda_4/AWSLambda-SQS.StartupProjects.txt b/samples/aws/lambda-sqs/SQSLambda_4/AWSLambda-SQS.StartupProjects.txt new file mode 100644 index 00000000000..0ea702707fa --- /dev/null +++ b/samples/aws/lambda-sqs/SQSLambda_4/AWSLambda-SQS.StartupProjects.txt @@ -0,0 +1 @@ +RegularEndpoint\RegularEndpoint.csproj \ No newline at end of file diff --git a/samples/aws/lambda-sqs/SQSLambda_4/AWSLambda-SQS.sln b/samples/aws/lambda-sqs/SQSLambda_4/AWSLambda-SQS.sln new file mode 100644 index 00000000000..c8d0258f91d --- /dev/null +++ b/samples/aws/lambda-sqs/SQSLambda_4/AWSLambda-SQS.sln @@ -0,0 +1,44 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29728.190 +MinimumVisualStudioVersion = 15.0.26730.12 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServerlessEndpoint", "ServerlessEndpoint\ServerlessEndpoint.csproj", "{D9FB3A23-D74F-4754-9A22-ACF829EEEB70}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RegularEndpoint", "RegularEndpoint\RegularEndpoint.csproj", "{06754C55-CA74-4F17-9472-244B8A3FEB1E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Messages", "Messages\Messages.csproj", "{1BEFE981-8E75-4152-B6E3-8D488AE8530F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D9FB3A23-D74F-4754-9A22-ACF829EEEB70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D9FB3A23-D74F-4754-9A22-ACF829EEEB70}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D9FB3A23-D74F-4754-9A22-ACF829EEEB70}.Debug|x64.ActiveCfg = Debug|Any CPU + {D9FB3A23-D74F-4754-9A22-ACF829EEEB70}.Debug|x64.Build.0 = Debug|Any CPU + {D9FB3A23-D74F-4754-9A22-ACF829EEEB70}.Debug|x86.ActiveCfg = Debug|Any CPU + {D9FB3A23-D74F-4754-9A22-ACF829EEEB70}.Debug|x86.Build.0 = Debug|Any CPU + {06754C55-CA74-4F17-9472-244B8A3FEB1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {06754C55-CA74-4F17-9472-244B8A3FEB1E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {06754C55-CA74-4F17-9472-244B8A3FEB1E}.Debug|x64.ActiveCfg = Debug|Any CPU + {06754C55-CA74-4F17-9472-244B8A3FEB1E}.Debug|x64.Build.0 = Debug|Any CPU + {06754C55-CA74-4F17-9472-244B8A3FEB1E}.Debug|x86.ActiveCfg = Debug|Any CPU + {06754C55-CA74-4F17-9472-244B8A3FEB1E}.Debug|x86.Build.0 = Debug|Any CPU + {1BEFE981-8E75-4152-B6E3-8D488AE8530F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1BEFE981-8E75-4152-B6E3-8D488AE8530F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1BEFE981-8E75-4152-B6E3-8D488AE8530F}.Debug|x64.ActiveCfg = Debug|Any CPU + {1BEFE981-8E75-4152-B6E3-8D488AE8530F}.Debug|x64.Build.0 = Debug|Any CPU + {1BEFE981-8E75-4152-B6E3-8D488AE8530F}.Debug|x86.ActiveCfg = Debug|Any CPU + {1BEFE981-8E75-4152-B6E3-8D488AE8530F}.Debug|x86.Build.0 = Debug|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6C66C18C-5075-4811-AF40-2997E8863F3B} + EndGlobalSection +EndGlobal diff --git a/samples/aws/lambda-sqs/SQSLambda_4/Messages/Messages.csproj b/samples/aws/lambda-sqs/SQSLambda_4/Messages/Messages.csproj new file mode 100644 index 00000000000..a75a84a7e09 --- /dev/null +++ b/samples/aws/lambda-sqs/SQSLambda_4/Messages/Messages.csproj @@ -0,0 +1,13 @@ + + + + net10.0 + preview + enable + + + + + + + \ No newline at end of file diff --git a/samples/aws/lambda-sqs/SQSLambda_4/Messages/ResponseMessage.cs b/samples/aws/lambda-sqs/SQSLambda_4/Messages/ResponseMessage.cs new file mode 100644 index 00000000000..db878746170 --- /dev/null +++ b/samples/aws/lambda-sqs/SQSLambda_4/Messages/ResponseMessage.cs @@ -0,0 +1,3 @@ +public class ResponseMessage : IMessage +{ +} \ No newline at end of file diff --git a/samples/aws/lambda-sqs/SQSLambda_4/Messages/TriggerMessage.cs b/samples/aws/lambda-sqs/SQSLambda_4/Messages/TriggerMessage.cs new file mode 100644 index 00000000000..5fdff415021 --- /dev/null +++ b/samples/aws/lambda-sqs/SQSLambda_4/Messages/TriggerMessage.cs @@ -0,0 +1,3 @@ +public class TriggerMessage : IMessage +{ +} \ No newline at end of file diff --git a/samples/aws/lambda-sqs/SQSLambda_4/RegularEndpoint/Program.cs b/samples/aws/lambda-sqs/SQSLambda_4/RegularEndpoint/Program.cs new file mode 100644 index 00000000000..9197a38e47a --- /dev/null +++ b/samples/aws/lambda-sqs/SQSLambda_4/RegularEndpoint/Program.cs @@ -0,0 +1,46 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +Console.Title = "RegularEndpoint"; + +var builder = Host.CreateApplicationBuilder(args); + +var endpointConfiguration = new EndpointConfiguration("RegularEndpoint"); +endpointConfiguration.UseSerialization(); +endpointConfiguration.UseTransport(); + +builder.UseNServiceBus(endpointConfiguration); + +var host = builder.Build(); +await host.StartAsync(); + +// Get the required services +var messageSession = host.Services.GetRequiredService(); +// Register a cancellation token to gracefully handle application shutdown +var ct = host.Services.GetRequiredService().ApplicationStopping; + +Console.WriteLine("Press [ENTER] to send a message to the serverless endpoint queue."); +Console.WriteLine("Press Ctrl+C to shut down."); + +// Wait for user input to publish messages +while (!ct.IsCancellationRequested) +{ + if (!Console.KeyAvailable) + { + // If no key is pressed, wait for a short time before checking again + await Task.Delay(100, CancellationToken.None); + continue; + } + + var key = Console.ReadKey(); + Console.WriteLine(); + + if (key.Key == ConsoleKey.Enter) + { + await messageSession.Send("ServerlessEndpoint", new TriggerMessage()); + Console.WriteLine("Message sent to the serverless endpoint queue."); + } +} + +// Wait for the host to stop gracefully +await host.StopAsync(); \ No newline at end of file diff --git a/samples/aws/lambda-sqs/SQSLambda_4/RegularEndpoint/RegularEndpoint.csproj b/samples/aws/lambda-sqs/SQSLambda_4/RegularEndpoint/RegularEndpoint.csproj new file mode 100644 index 00000000000..178166e436a --- /dev/null +++ b/samples/aws/lambda-sqs/SQSLambda_4/RegularEndpoint/RegularEndpoint.csproj @@ -0,0 +1,19 @@ + + + + net10.0 + Exe + preview + enable + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/aws/lambda-sqs/SQSLambda_4/RegularEndpoint/ResponseMessageHandler.cs b/samples/aws/lambda-sqs/SQSLambda_4/RegularEndpoint/ResponseMessageHandler.cs new file mode 100644 index 00000000000..4247f932553 --- /dev/null +++ b/samples/aws/lambda-sqs/SQSLambda_4/RegularEndpoint/ResponseMessageHandler.cs @@ -0,0 +1,10 @@ +using Microsoft.Extensions.Logging; + +public class ResponseMessageHandler(ILogger logger) : IHandleMessages +{ + public Task Handle(ResponseMessage message, IMessageHandlerContext context) + { + logger.LogInformation("Handling {MessageType} in RegularEndpoint", nameof(ResponseMessage)); + return Task.CompletedTask; + } +} \ No newline at end of file diff --git a/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/EndpontConfiguration.cs b/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/EndpontConfiguration.cs new file mode 100644 index 00000000000..10a944185c8 --- /dev/null +++ b/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/EndpontConfiguration.cs @@ -0,0 +1,19 @@ +namespace LambdaFunctions; + +public static class Endpoint +{ + #region EndpointSetup + public static IAwsLambdaSQSEndpoint Configuration => new AwsLambdaSQSEndpoint(context => + { + var endpointConfiguration = new AwsLambdaSQSEndpointConfiguration("ServerlessEndpoint"); + endpointConfiguration.UseSerialization(); + + var routing = endpointConfiguration.RoutingSettings; + + routing.RouteToEndpoint(typeof(TriggerMessage), "ServerlessEndpoint"); + routing.RouteToEndpoint(typeof(ResponseMessage), "RegularEndpoint"); + + return endpointConfiguration; + }); + #endregion +} \ No newline at end of file diff --git a/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/HttpLambda.cs b/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/HttpLambda.cs new file mode 100644 index 00000000000..98a7432e55d --- /dev/null +++ b/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/HttpLambda.cs @@ -0,0 +1,25 @@ +using Amazon.Lambda.Annotations; +using Amazon.Lambda.Annotations.APIGateway; +using Amazon.Lambda.Core; + +// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class. +[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))] + +namespace LambdaFunctions +{ + public class HttpLambda + { + #region HttpFunctionHandler + [LambdaFunction(Policies = "AWSLambda_FullAccess, AmazonSQSFullAccess")] + [HttpApi(LambdaHttpMethod.Get, "/")] + public async Task HttpGetHandler(ILambdaContext context) + { + await serverlessEndpoint.Send(new TriggerMessage(), context); + return $"{nameof(TriggerMessage)} sent."; + } + + #endregion + + static readonly IAwsLambdaSQSEndpoint serverlessEndpoint = Endpoint.Configuration; + } +} \ No newline at end of file diff --git a/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/Properties/launchSettings.json b/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/Properties/launchSettings.json new file mode 100644 index 00000000000..c1fabf8f854 --- /dev/null +++ b/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "Mock Lambda Test Tool": { + "commandName": "Executable", + "commandLineArgs": "--port 5050", + "workingDirectory": ".\\bin\\$(Configuration)\\net8.0", + "executablePath": "%USERPROFILE%\\.dotnet\\tools\\dotnet-lambda-test-tool-8.0.exe" + } + } +} \ No newline at end of file diff --git a/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/ServerlessEndpoint.csproj b/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/ServerlessEndpoint.csproj new file mode 100644 index 00000000000..9aa3ebdb665 --- /dev/null +++ b/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/ServerlessEndpoint.csproj @@ -0,0 +1,26 @@ + + + + net10.0 + true + Lambda + preview + enable + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/ServerlessEndpoint.sln b/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/ServerlessEndpoint.sln new file mode 100644 index 00000000000..44a7154a537 --- /dev/null +++ b/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/ServerlessEndpoint.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.2.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerlessEndpoint", "ServerlessEndpoint.csproj", "{5203F0FC-9459-4724-C2D4-BA60791FED68}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5203F0FC-9459-4724-C2D4-BA60791FED68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5203F0FC-9459-4724-C2D4-BA60791FED68}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5203F0FC-9459-4724-C2D4-BA60791FED68}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5203F0FC-9459-4724-C2D4-BA60791FED68}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6FBD541B-2DD7-43F4-9807-269CEA802E90} + EndGlobalSection +EndGlobal diff --git a/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/SqsLambda.cs b/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/SqsLambda.cs new file mode 100644 index 00000000000..2b1b9ddc53d --- /dev/null +++ b/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/SqsLambda.cs @@ -0,0 +1,21 @@ +using Amazon.Lambda.Core; +using Amazon.Lambda.SQSEvents; + +namespace LambdaFunctions +{ + public class SqsLambda + { + #region SqsFunctionHandler + public async Task FunctionHandler(SQSEvent evnt, ILambdaContext context) + { + using var cancellationTokenSource = + new CancellationTokenSource(context.RemainingTime.Subtract(DefaultRemainingTimeGracePeriod)); + + await serverlessEndpoint.Process(evnt, context, cancellationTokenSource.Token); + } + #endregion + + static readonly TimeSpan DefaultRemainingTimeGracePeriod = TimeSpan.FromSeconds(10); + static readonly IAwsLambdaSQSEndpoint serverlessEndpoint = Endpoint.Configuration; + } +} \ No newline at end of file diff --git a/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/TriggerMessageHandler.cs b/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/TriggerMessageHandler.cs new file mode 100644 index 00000000000..8c053b0021c --- /dev/null +++ b/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/TriggerMessageHandler.cs @@ -0,0 +1,14 @@ +using NServiceBus.Logging; + +#region TriggerMessageHandler +public class TriggerMessageHandler : IHandleMessages +{ + static readonly ILog Log = LogManager.GetLogger(); + + public async Task Handle(TriggerMessage message, IMessageHandlerContext context) + { + Log.Info($"Handling {nameof(TriggerMessage)} in ServerlessEndpoint."); + await context.Send(new ResponseMessage()); + } +} +#endregion \ No newline at end of file diff --git a/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/aws-lambda-tools-defaults.json b/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/aws-lambda-tools-defaults.json new file mode 100644 index 00000000000..9674dfd454d --- /dev/null +++ b/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/aws-lambda-tools-defaults.json @@ -0,0 +1,16 @@ +{ + "Information": [ + "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.", + "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.", + "dotnet lambda help", + "All the command line options for the Lambda command can be specified in this file." + ], + "profile": "default", + "region": "ap-southeast-2", + "configuration": "Debug", + "framework": "net8.0", + "template": "serverless.template", + "template-parameters": "", + "stack-name": "nservicebus-aws-lambda-sample-jtd", + "s3-bucket": "nservicebus-aws-lambda-sample-jtd" +} \ No newline at end of file diff --git a/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/serverless.template b/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/serverless.template new file mode 100644 index 00000000000..1917b5820f7 --- /dev/null +++ b/samples/aws/lambda-sqs/SQSLambda_4/ServerlessEndpoint/serverless.template @@ -0,0 +1,133 @@ +{ + "AWSTemplateFormatVersion": "2010-09-09", + "Transform": "AWS::Serverless-2016-10-31", + "Description": "Template that creates an SQS queue and a function that is invoked when a new message arrives. This template is partially managed by Amazon.Lambda.Annotations (v1.7.0.0).", + "Resources": { + "ErrorQueue": { + "Properties": { + "QueueName": "error" + }, + "Type": "AWS::SQS::Queue" + }, + "RegularEndpointQueue": { + "Properties": { + "QueueName": "RegularEndpoint" + }, + "Type": "AWS::SQS::Queue" + }, + "RegularEndpointDelayQueue": { + "Type": "AWS::SQS::Queue", + "Properties": { + "QueueName": "RegularEndpoint-delay.fifo", + "FifoQueue": "true", + "DelaySeconds": 900 + } + }, + "ServerlessEndpointQueue": { + "Properties": { + "QueueName": "ServerlessEndpoint" + }, + "Type": "AWS::SQS::Queue" + }, + "ServerlessEndpointDelayQueue": { + "Type": "AWS::SQS::Queue", + "Properties": { + "QueueName": "ServerlessEndpoint-delay.fifo", + "FifoQueue": "true", + "DelaySeconds": 900 + } + }, + "SQSTriggerFunction": { + "Type": "AWS::Serverless::Function", + "Properties": { + "Handler": "ServerlessEndpoint::LambdaFunctions.SqsLambda::FunctionHandler", + "Runtime": "dotnet8", + "CodeUri": "", + "Description": "Function handling sqs events produced by pushing messages to the ServerlessEndpoint queue", + "MemorySize": 256, + "Timeout": 30, + "Role": null, + "Policies": [ + "AWSLambda_FullAccess", + "AmazonSQSFullAccess" + ], + "Events": { + "SqsEvent": { + "Type": "SQS", + "Properties": { + "BatchSize": 10, + "Queue": { + "Fn::GetAtt": [ + "ServerlessEndpointQueue", + "Arn" + ] + } + } + } + } + } + }, + "LambdaFunctionsHttpLambdaHttpGetHandlerGenerated": { + "Type": "AWS::Serverless::Function", + "Metadata": { + "Tool": "Amazon.Lambda.Annotations", + "SyncedEvents": [ + "RootGet" + ], + "SyncedEventProperties": { + "RootGet": [ + "Path", + "Method" + ] + } + }, + "Properties": { + "Runtime": "dotnet6", + "CodeUri": ".", + "MemorySize": 256, + "Timeout": 30, + "Policies": [ + "AWSLambda_FullAccess", + "AmazonSQSFullAccess" + ], + "PackageType": "Zip", + "Handler": "ServerlessEndpoint::LambdaFunctions.HttpLambda_HttpGetHandler_Generated::HttpGetHandler", + "Events": { + "RootGet": { + "Type": "HttpApi", + "Properties": { + "Path": "/", + "Method": "GET" + } + } + } + } + } + }, + "Outputs": { + "ApiURL": { + "Description": "API endpoint URL of the HttpGet trigger function", + "Value": { + "Fn::Sub": "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com/" + } + }, + "ErrorQueueURL": { + "Description": "The URL of the queue", + "Value": { + "Ref": "ErrorQueue" + } + }, + "ServerlessEndpointQueueURL": { + "Description": "The URL of the serverless endpoint queue", + "Value": { + "Ref": "ServerlessEndpointQueue" + } + }, + "RegularEndpointQueueURL": { + "Description": "The URL of the on premise endpoint queue", + "Value": { + "Ref": "RegularEndpointQueue" + } + } + } +} \ No newline at end of file diff --git a/samples/aws/lambda-sqs/SQSLambda_4/prerelease.txt b/samples/aws/lambda-sqs/SQSLambda_4/prerelease.txt new file mode 100644 index 00000000000..e69de29bb2d