Giter VIP home page Giter VIP logo

stacks-dotnet-packages-sns's Introduction

Amido Stacks Messaging AWS SNS

This library is wrapper around Amazon Simple Notification Service. The main goals are:

  1. To publish messages to a configured SNS topic.
  2. To receive messages from a configured SNS topic.

1. Requirements

You will need an SNS instance in order to use this library. To create an SNS instance, you can follow the instructions in the AWS SNS Documentation.

2. Registration/Usage

2.1 Dependencies

  • Amido.Stacks.Application.CQRS.Abstractions
  • Amido.Stacks.Configuration
  • Amido.Stacks.Core
  • AWSSDK.SimpleNotificationService

2.2 Currently Supported messages

The library currently supports:

  • Publishing and receiving events that implement Amido.Stacks.Application.CQRS.ApplicationEvents.IApplicationEvent.

2.3 Usage in dotnet application

2.3.1 Event

In this example the MenuCreatedEvent is handled by the MenuCreatedEventHandler. The event must implement the IApplicationEvent interface and the handler must implement the IApplicationEventHandler<NotifyEvent> interface. Both of these interfaces are found in the Amido.Stacks.Application.CQRS.ApplicationEvents namespace.

MenuCreated.cs

public class MenuCreatedEvent : IApplicationEvent
{
    public MenuCreatedEvent(Guid correlationId, int eventCode, int operationCode)
    {
        CorrelationId = correlationId;
        EventCode = eventCode;
        OperationCode = operationCode;
    }

    public Guid CorrelationId { get; }
    public int EventCode { get; }
    public int OperationCode { get; }
}

MenuCreatedHandler.cs

public class MenuCreatedEventHandler : IApplicationEventHandler<MenuCreatedEvent>
{
    public Task HandleAsync(MenuCreatedEvent applicationEvent)
    {
       //  Code to handle the event...
        return Task.CompletedTask;
    }
}

2.3.1.1 AWS Options Configuration

appsettings.json

{
  "AwsSnsConfiguration": {
      "TopicArn": {
        "Identifier": "TOPIC_ARN",
        "Source": "Environment"
      }
  }
}

Usage

public class Startup
{
    public void ConfigureServices(IServiceCollection services, WebHostBuilderContext context)
    {
        services.Configure<AwsSnsConfiguration>(context.Configuration.GetSection("AwsSnsConfiguration"));
        services.AddAwsSns(context.Configuration);
         services.AddSecrets();  // To read the secret defined as an environment variable appsettings.json.
    }
}

stacks-dotnet-packages-sns's People

Contributors

alexanderwjrussell avatar andyhale avatar elvenspellmaker avatar underscorehao avatar

Watchers

Simon Evans avatar Richard Slater avatar Radoslaw Orlowski avatar  avatar Rob Selway avatar  avatar Christopher Butler avatar Lee Saxby avatar  avatar Sharon Russell avatar Andrew Waite avatar

Forkers

andyhale

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.