Skip to content

Commit 016f28a

Browse files
Clone SQSLambda_3
1 parent 564711e commit 016f28a

16 files changed

+404
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
RegularEndpoint\RegularEndpoint.csproj
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29728.190
5+
MinimumVisualStudioVersion = 15.0.26730.12
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServerlessEndpoint", "ServerlessEndpoint\ServerlessEndpoint.csproj", "{D9FB3A23-D74F-4754-9A22-ACF829EEEB70}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RegularEndpoint", "RegularEndpoint\RegularEndpoint.csproj", "{06754C55-CA74-4F17-9472-244B8A3FEB1E}"
9+
EndProject
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Messages", "Messages\Messages.csproj", "{1BEFE981-8E75-4152-B6E3-8D488AE8530F}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Debug|x64 = Debug|x64
16+
Debug|x86 = Debug|x86
17+
EndGlobalSection
18+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
19+
{D9FB3A23-D74F-4754-9A22-ACF829EEEB70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20+
{D9FB3A23-D74F-4754-9A22-ACF829EEEB70}.Debug|Any CPU.Build.0 = Debug|Any CPU
21+
{D9FB3A23-D74F-4754-9A22-ACF829EEEB70}.Debug|x64.ActiveCfg = Debug|Any CPU
22+
{D9FB3A23-D74F-4754-9A22-ACF829EEEB70}.Debug|x64.Build.0 = Debug|Any CPU
23+
{D9FB3A23-D74F-4754-9A22-ACF829EEEB70}.Debug|x86.ActiveCfg = Debug|Any CPU
24+
{D9FB3A23-D74F-4754-9A22-ACF829EEEB70}.Debug|x86.Build.0 = Debug|Any CPU
25+
{06754C55-CA74-4F17-9472-244B8A3FEB1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{06754C55-CA74-4F17-9472-244B8A3FEB1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{06754C55-CA74-4F17-9472-244B8A3FEB1E}.Debug|x64.ActiveCfg = Debug|Any CPU
28+
{06754C55-CA74-4F17-9472-244B8A3FEB1E}.Debug|x64.Build.0 = Debug|Any CPU
29+
{06754C55-CA74-4F17-9472-244B8A3FEB1E}.Debug|x86.ActiveCfg = Debug|Any CPU
30+
{06754C55-CA74-4F17-9472-244B8A3FEB1E}.Debug|x86.Build.0 = Debug|Any CPU
31+
{1BEFE981-8E75-4152-B6E3-8D488AE8530F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32+
{1BEFE981-8E75-4152-B6E3-8D488AE8530F}.Debug|Any CPU.Build.0 = Debug|Any CPU
33+
{1BEFE981-8E75-4152-B6E3-8D488AE8530F}.Debug|x64.ActiveCfg = Debug|Any CPU
34+
{1BEFE981-8E75-4152-B6E3-8D488AE8530F}.Debug|x64.Build.0 = Debug|Any CPU
35+
{1BEFE981-8E75-4152-B6E3-8D488AE8530F}.Debug|x86.ActiveCfg = Debug|Any CPU
36+
{1BEFE981-8E75-4152-B6E3-8D488AE8530F}.Debug|x86.Build.0 = Debug|Any CPU
37+
EndGlobalSection
38+
GlobalSection(SolutionProperties) = preSolution
39+
HideSolutionNode = FALSE
40+
EndGlobalSection
41+
GlobalSection(ExtensibilityGlobals) = postSolution
42+
SolutionGuid = {6C66C18C-5075-4811-AF40-2997E8863F3B}
43+
EndGlobalSection
44+
EndGlobal
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<LangVersion>12.0</LangVersion>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="NServiceBus" Version="9.*" />
10+
</ItemGroup>
11+
12+
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
using NServiceBus;
2+
3+
public class ResponseMessage : IMessage;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
using NServiceBus;
2+
3+
public class TriggerMessage : IMessage;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using NServiceBus;
3+
4+
Console.Title = "RegularEndpoint";
5+
6+
var endpointConfiguration = new EndpointConfiguration("RegularEndpoint");
7+
8+
endpointConfiguration.UseSerialization<SystemJsonSerializer>();
9+
endpointConfiguration.UseTransport<SqsTransport>();
10+
11+
var endpointInstance = await Endpoint.Start(endpointConfiguration);
12+
13+
Console.WriteLine("Press [ENTER] to send a message to the serverless endpoint queue.");
14+
Console.WriteLine("Press [Esc] to exit.");
15+
16+
while (true)
17+
{
18+
var key = Console.ReadKey();
19+
Console.WriteLine();
20+
switch (key.Key)
21+
{
22+
case ConsoleKey.Enter:
23+
await endpointInstance.Send("ServerlessEndpoint", new TriggerMessage());
24+
Console.WriteLine("Message sent to the serverless endpoint queue.");
25+
break;
26+
case ConsoleKey.Escape:
27+
await endpointInstance.Stop();
28+
return;
29+
}
30+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<OutputType>Exe</OutputType>
6+
<LangVersion>12.0</LangVersion>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="..\Messages\Messages.csproj" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="NServiceBus.AmazonSQS" Version="7.*" />
15+
</ItemGroup>
16+
17+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Threading.Tasks;
2+
using NServiceBus;
3+
using NServiceBus.Logging;
4+
5+
public class ResponseMessageHandler : IHandleMessages<ResponseMessage>
6+
{
7+
static readonly ILog Log = LogManager.GetLogger<ResponseMessageHandler>();
8+
9+
public Task Handle(ResponseMessage message, IMessageHandlerContext context)
10+
{
11+
Log.Info($"Handling {nameof(ResponseMessage)} in RegularEndpoint");
12+
return Task.CompletedTask;
13+
}
14+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.Threading.Tasks;
2+
using Amazon.Lambda.Annotations;
3+
using Amazon.Lambda.Annotations.APIGateway;
4+
using Amazon.Lambda.Core;
5+
using Amazon.Lambda.Serialization.SystemTextJson;
6+
using NServiceBus;
7+
8+
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
9+
[assembly:LambdaSerializer(typeof(DefaultLambdaJsonSerializer))]
10+
11+
namespace LambdaFunctions;
12+
13+
public class HttpLambda(IAwsLambdaSQSEndpoint serverlessEndpoint)
14+
{
15+
#region HttpFunctionHandler
16+
[LambdaFunction(Policies = "AWSLambda_FullAccess, AmazonSQSFullAccess")]
17+
[HttpApi(LambdaHttpMethod.Get, "/")]
18+
public async Task<string> HttpGetHandler(ILambdaContext context)
19+
{
20+
await serverlessEndpoint.Send(new TriggerMessage(), context);
21+
return $"{nameof(TriggerMessage)} sent.";
22+
}
23+
#endregion
24+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"profiles": {
3+
"Mock Lambda Test Tool": {
4+
"commandName": "Executable",
5+
"commandLineArgs": "--port 5050",
6+
"workingDirectory": ".\\bin\\$(Configuration)\\net8.0",
7+
"executablePath": "%USERPROFILE%\\.dotnet\\tools\\dotnet-lambda-test-tool-8.0.exe"
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)