NiceNotice.Aws.Sns
0.1.0
dotnet add package NiceNotice.Aws.Sns --version 0.1.0
NuGet\Install-Package NiceNotice.Aws.Sns -Version 0.1.0
<PackageReference Include="NiceNotice.Aws.Sns" Version="0.1.0" />
<PackageVersion Include="NiceNotice.Aws.Sns" Version="0.1.0" />
<PackageReference Include="NiceNotice.Aws.Sns" />
paket add NiceNotice.Aws.Sns --version 0.1.0
#r "nuget: NiceNotice.Aws.Sns, 0.1.0"
#:package NiceNotice.Aws.Sns@0.1.0
#addin nuget:?package=NiceNotice.Aws.Sns&version=0.1.0
#tool nuget:?package=NiceNotice.Aws.Sns&version=0.1.0
NiceNotice.Aws.Sns: SNS I/O adapters for NiceNotice
NiceNotice.Aws.Sns provides Amazon Web Services (AWS) I/O adapters for NiceNotice cross-application notifications which dispatches notifications to Amazon Simple Notification Service (SNS).
This project is not affiliated with Amazon or Amazon Web Services.
How to use
- Install the
NiceNotice.Aws.SnsNuGet package in your application.- Consider adding the
NiceNoticepackage as well, so you can update core NiceNotice features.
- Consider adding the
- Configure AWS SNS in your application.
- Make sure that your application's service registrations include
Amazon.SimpleNotificationService.IAmazonSimpleNotificationService. That is the AWS SNS abstraction upon which this library depends.
- Make sure that your application's service registrations include
- Add NiceNotice service registrations to your application.
- Configure NiceNotice, including choosing a "base" event notification type. See examples in NiceNotice documentation.
- This is a perfect time to think about the logical "streams" of notifications you'll send. For example, logically sending account creation notifications to a different stream than request timing metrics, which is potentially different again to error notifications. By default, NiceNotice sends each notice to a logical stream matching the notification type name. E.g.,
public class SignInEvent : MyBaseType {}would route to aSignInEventstream. To override this and specify a custom stream name, add a[NoticeStream()]attribute to your notification type.
- This is a perfect time to think about the logical "streams" of notifications you'll send. For example, logically sending account creation notifications to a different stream than request timing metrics, which is potentially different again to error notifications. By default, NiceNotice sends each notice to a logical stream matching the notification type name. E.g.,
- Use
.DispatchToSns()in the NiceNotice configuration, to enable SNS dispatch. - Update application configuration to specify SNS topic routing.
- Make sure to set the
Defaulttopic ARN in application configuration (see below).
- Make sure to set the
- Configure NiceNotice, including choosing a "base" event notification type. See examples in NiceNotice documentation.
- Start using NiceNotice!
- To send notifications:
- Add
Jds.NiceNotice.ITypedNoticeDispatcher<YourApplicationBaseEventType>to your application services' constructor (e.g., ASP.NET Core controllers and other registered services). - Use its
DispatchAsync()method to send individual notifications. - Or use its
DispatchBatchAsync<YourApplicationBaseEventType>method to send batches of notifications.
- Add
- To send notifications:
Simple Example Service Registration
The snippet below shows how NiceNotice can be arranged to send notices to AWS SNS.
This code would exist in Program.cs, Startup.cs, or similar location where the root application IServiceCollection is arranged.
In this example, the developer created a new class MyApplicationEvent which is the base "value object" type for their application's notices.
Additionally, they've chosen to store their configuration mapping their notifications' logical "streams" to AWS SNS topics in a configuration section named sns:topics. (See configuration section below for more details.)
services
.AddNiceNotice(builder => builder
.UseTypedNotices<MyApplicationEvent>(
// By default, notices will be serialized to JSON and routed to logical streams based on their type name.
// Here, we're enabling data attributes validation, for extra data
new TypedNoticesBuilderOptions
{
ValidationType = TypedNoticesBuilderOptions.ValidationTypes.DataAttributes
},
ServiceLifetime.Scoped
)
.DispatchToSns( // Dispatch enterprise events to AWS SNS.
"sns:topics", // IConfiguration section key; should match your application configuration
ServiceLifetime.Scoped
)
);
Given the above configuration, the minimum configuration required to successfully send a notice to SNS would be to set the default SNS topic.
In the configuration above, the developer decided to store their SNS routing in the sns:topics configuration section. Configuring the default SNS topic is done by setting the default property in the configured section to the desired SNS topic ARN.
For example, provide a SNS__TOPICS__DEFAULT="arn:aws:sns:eu-west-1:123456789012:example-topic" environment variable, or set the $.sns.topics.default property in the application's appsettings.json file.
Configuring NiceNotice.Aws.Sns (Routing Notifications to SNS Topics)
Routing serialized notifications to AWS SNS topics is a key implementation concern when adding SNS I/O to NiceNotice (via .DispatchToSns()).
The recommended way to configure SNS topic routing is by using the .DispatchToSns() overload which accepts a string configurationSectionPath (as shown in the example above). At runtime, the configuration of NiceNotice routing to SNS topics will be bound to the IConfiguration section key in application configuration. That configuration section will be parsed as a ConfigurationSnsTopicOptions object. There is no default configuration section assumed by NiceNotice; it must be chosen by the developer. Note that when loading SNS topic routing via configuration, all configured sources will be used (e.g., environment variables, appsettings.json files).
Fortunately, the configuration is very simple. As seen in ConfigurationSnsTopicOptions, there are two configuration properties. Both are optional, but incomplete configuration can result in runtime exceptions.
Default: Recommended A default AWS SNS topic to which notifications will be sent if no topic for its NiceNotice stream is configured inStreams.Streams: A dictionary ofstring niceNoticeEventStream(key) tostring awsSnsTopicArn(value).
Example Configuration in a appsettings.json File
In the file below, the developer has chosen to use the InterAppNotifications:SnsRouting configuration path.
In this hypothetical application there is a default SNS topic specified for all notifications not mapped in Streams.
Notice that the Streams shows three type name mappings. From that we can infer that NiceNotice typed notices are configured with RoutingType = TypedNoticeConfigurationExtensions.RoutingTypes.TypeFullName. (See the example service registration above for that setting in context.)
{
"InterAppNotifications": {
"SnsRouting": {
"Default": "arn:aws:sns:eu-west-1:123456789012:example-topic",
"Streams": {
"MyApp.XappNotices.SignIn": "arn:aws:sns:us-east-1:123456789012:user-sessions",
"MyApp.XappNotices.SignOut": "arn:aws:sns:us-east-1:123456789012:user-sessions",
"MyApp.XappNotices.RevokeSession": "arn:aws:sns:us-east-1:123456789012:user-sessions"
}
}
}
}
Equivalent Configuration in Environment Variables
Below is an equivalent configuration to the appsettings.json shown above.
InterAppNotifications__SnsRouting__Default="arn:aws:sns:eu-west-1:123456789012:example-topic"
InterAppNotifications__SnsRouting__Streams__MyApp.XappNotices.SignIn="arn:aws:sns:us-east-1:123456789012:user-sessions"
InterAppNotifications__SnsRouting__Streams__MyApp.XappNotices.SignOut="arn:aws:sns:us-east-1:123456789012:user-sessions"
InterAppNotifications__SnsRouting__Streams__MyApp.XappNotices.RevokeSession="arn:aws:sns:us-east-1:123456789012:user-sessions"
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- AWSSDK.Core (>= 4.0.3.3)
- AWSSDK.SimpleNotificationService (>= 4.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- NiceNotice (>= 0.1.0)
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.1.0 | 229 | 4/8/2026 |
| 0.1.0-build-20260330-042859... | 144 | 3/30/2026 |
| 0.1.0-build-20260330-011719... | 102 | 3/30/2026 |
| 0.1.0-build-20260315-181614... | 146 | 3/15/2026 |
| 0.1.0-build-20260227-002733... | 109 | 2/27/2026 |
| 0.1.0-build-20251101-233529... | 167 | 11/1/2025 |
| 0.1.0-build-20251006-012014... | 214 | 10/6/2025 |