Skip to content

Commit

Permalink
Wired up SQS message handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Kralizek committed Nov 10, 2022
1 parent 179d57b commit 44e696f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 19 additions & 1 deletion SqsEventHandlerFunction/Function.cs
@@ -1,5 +1,7 @@
using System.Collections.Generic;
using Amazon.Lambda.Core;
using Amazon.Lambda.SQSEvents;
using Amazon.SimpleNotificationService;
using Kralizek.Lambda;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -11,8 +13,24 @@ namespace SqsEventHandlerFunction;

public class Function : EventFunction<SQSEvent>
{
protected override void Configure(IConfigurationBuilder builder)
{
builder.AddInMemoryCollection(new Dictionary<string, string>
{
["Options:TopicArn"] = "ARN of my SNS topic"
});
}

protected override void ConfigureServices(IServiceCollection services, IExecutionEnvironment executionEnvironment)
{
services.UseQueueMessageHandler<Entry, SqsMessageHandler>();
services.UseQueueMessageHandler<Entry, SqsMessageHandler>().WithParallelExecution();

services.AddAWSService<IAmazonSimpleNotificationService>();

services.Configure<SqsMessageHandlerOptions>(Configuration.GetSection("Options"));

services.UseCustomMessageSerializer<CustomSerializer>();

services.AddSingleton<IItemProcessor, NullItemProcessor>();
}
}
4 changes: 3 additions & 1 deletion SqsEventHandlerFunction/SqsEventHandlerFunction.csproj
Expand Up @@ -10,9 +10,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.EXtensions.NETCore.Setup" Version="3.7.2" />
<PackageReference Include="AWSSDK.SimpleNotificationService" Version="3.7.100.9" />
<PackageReference Include="Kralizek.Lambda.Template" Version="5.0.0" />
<PackageReference Include="Kralizek.Lambda.Template.Sqs" Version="5.0.0" />
<PackageReference Include="Kralizek.Lambda.Template.Sqs" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" />
</ItemGroup>

</Project>

0 comments on commit 44e696f

Please sign in to comment.