Skip to content

JGMelon22/HelloSQS

Repository files navigation

AmazonSQS.Demo

This project demonstrates the implementation of a messaging system using Amazon SQS (Simple Queue Service) with a producer-consumer architecture. The system uses ElasticMQ to simulate SQS locally during development and testing.


🚀 Motivation

This project was created to learn and master technologies used in my current workplace, which relies on the AWS stack, along with curiosity to explore modern development patterns:

  • Amazon SQS: Understanding asynchronous messaging and distributed systems
  • NUnit: Learning structured and reliable unit testing
  • NSubstitute: Mastering mocking techniques to isolate dependencies in tests
  • Options Pattern: Applying .NET configuration patterns

🗺️ Project Structure

HelloSQS
├── src
│   ├── AmazonSQS.Core                      # Domain layer
│   │   └── Domains
│   │       ├── DTOs                        # Data Transfer Objects
│   │       │   ├── Requests
│   │       │   └── Responses
│   │       ├── Entities                    # Domain entities
│   │       └── Mappings                    # Object mappings
│   │
│   ├── AmazonSQS.Infrastructure            # Infrastructure layer
│   │   ├── BackgroundServices              # Processing workers
│   │   ├── Configuration                   # Configurations (Options Pattern)
│   │   ├── Interfaces
│   │   │   └── Services                    # Service contracts
│   │   └── Services                        # SQS service implementations
│   │
│   ├── Consumer.API                        # Consumer API
│   │   ├── Controllers                     # API endpoints
│   │   └── Middlewares                     # Custom middlewares
│   │
│   └── Consumer.Consumer                   # Consumer worker
│       └── Properties                      # Application properties
│
└── tests
    └── UnitTests
        └── AmazonSQS.Infrastructure.UnitTests  # Unit tests (NUnit + NSubstitute)
            └── Services                        # Service tests

🧰 Tech Stack

.NET Swagger Docker AWS

  • .NET 10 – Main backend framework
  • Swagger – Interactive API documentation
  • Amazon SQS – Message queuing service
  • ElasticMQ – Local Amazon SQS simulator
  • NUnit – Unit testing framework
  • NSubstitute – Mocking library for tests
  • Options Pattern – .NET configuration pattern

🏗️ Architecture

The project follows Clean Architecture and SOLID principles, with a well-defined message flow:

  1. The Producer API publishes messages to the SQS queue
  2. The Background Service continuously monitors the queue
  3. Messages are consumed, processed, and removed after success
  4. In case of failure, messages return to the queue for retry

⚙️ Configuration

Prerequisites

  • .NET 10 SDK
  • Docker (to run ElasticMQ)

Local ElasticMQ

Run ElasticMQ via Docker:

docker run -d --name ElasticMQ -p 9324:9324 softwaremill/elasticmq-native

Application Configuration

Configure in appsettings.json:

{
  "AWS": {
    "Region": "us-east-1",
    "ServiceURL": "http://localhost:9324",
    "QueueUrl": "http://localhost:9324/your-queue-name"
  }
}

🧪 Tests

Run unit tests:

dotnet test

🙏 Acknowledgments

  • ElasticMQ for providing an excellent local SQS simulation tool

About

Sample ASP .NET Core Web Project publishing and consuming SQS queue with ElasticMQ

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages