Davasorus.Utility.DotNet.SQS 2026.2.1.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Davasorus.Utility.DotNet.SQS --version 2026.2.1.2
                    
NuGet\Install-Package Davasorus.Utility.DotNet.SQS -Version 2026.2.1.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Davasorus.Utility.DotNet.SQS" Version="2026.2.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Davasorus.Utility.DotNet.SQS" Version="2026.2.1.2" />
                    
Directory.Packages.props
<PackageReference Include="Davasorus.Utility.DotNet.SQS" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Davasorus.Utility.DotNet.SQS --version 2026.2.1.2
                    
#r "nuget: Davasorus.Utility.DotNet.SQS, 2026.2.1.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Davasorus.Utility.DotNet.SQS@2026.2.1.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Davasorus.Utility.DotNet.SQS&version=2026.2.1.2
                    
Install as a Cake Addin
#tool nuget:?package=Davasorus.Utility.DotNet.SQS&version=2026.2.1.2
                    
Install as a Cake Tool

Davasorus.Utility.DotNet.SQS

Overview

Davasorus.Utility.DotNet.SQS provides utilities for publishing messages to Amazon Simple Queue Service (SQS) from .NET applications. It handles message serialization, error deduplication, anonymization, location enrichment, and OpenTelemetry tracing out of the box.

Features

  • Publish messages to AWS SQS FIFO and standard queues
  • Built-in error deduplication and anonymous error reporting
  • Location enrichment (city, region) via IP geolocation with configurable caching
  • OpenTelemetry distributed tracing on all operations
  • Secure credential management (decrypts AWS secrets at runtime)
  • Fluent configuration with SqsOptionsBuilder or appsettings.json binding
  • Designed for dependency injection with a single AddSqsLogging() call
  • Service-oriented usage: always interact with ISqsService, not the client directly

Getting Started

  1. Reference the library in your .NET 8 project.
  2. Register services using the AddSqsLogging() extension method.
  3. Use ISqsService in your application code to publish messages.

Dependency Injection

Register all SQS and location services with a single call:

// Default configuration (caching enabled, 1 hour location cache, 4 hour IP cache)
services.AddSqsLogging();

// Fluent configuration
services.AddSqsLogging(sqs => sqs
    .WithLocationCache(TimeSpan.FromHours(1))
    .WithIpCache(TimeSpan.FromHours(4)));

// Bind from appsettings.json
services.AddSqsLogging(configuration.GetSection("SqsOptions"));

// Hybrid: appsettings with fluent overrides
services.AddSqsLogging(
    configuration.GetSection("SqsOptions"),
    sqs => sqs.WithLocationCache(TimeSpan.FromMinutes(90)));

AddSqsLogging() registers the following services:

Service Lifetime Purpose
SqsOptions Singleton Configuration options
IMemoryCache Singleton Backing store for location cache
LocationCache Singleton IP and location caching
ILocationClient / LocationClient Transient Fetches location data from external APIs
ILocationService / LocationService Scoped Location operations interface
ISqsClient / SqsClient Transient Low-level SQS publishing
ISqsService / SqsService Scoped High-level SQS operations (use this)

Only inject and use ISqsService in your application code.

Usage Example

public class MyService
{
    private readonly ISqsService _sqsService;
    public MyService(ISqsService sqsService) => _sqsService = sqsService;

    public async Task LogErrorAsync(string message)
    {
        var model = new TrelloMessageQueueModel { Message = message /*, ... */ };
        await _sqsService.SendLoggingMessage(model);
    }
}

Configuration

SqsOptions

Configure caching and error collection behavior via SqsOptions:

Property Default Description
LocationCacheDurationMinutes 60 Duration to cache location data (city, region)
IpAddressCacheDurationMinutes 240 Duration to cache the public IP address
EnableLocationCaching true Enable/disable location caching entirely
MaxErrorCollectionSize 1000 Maximum tracked errors before FIFO eviction
LocationHttpTimeoutSeconds 10 Timeout for external location API calls
MaxConnectionsPerLocationServer 2 Max concurrent connections per location API server

AWS Credentials

Access Key and Secret Key are stored securely and decrypted at runtime via the IDecrypt service from Davasorus.Utility.DotNet.Encryption.

Queue Names

Queue names are managed internally by the service:

  • messageQueue.fifo -- general and logging messages
  • responseQueue.fifo -- response messages
  • systemMaint.fifo -- maintenance messages
  • taskQueue-{hostId}.fifo -- per-host task messages
  • taskQueue.fifo -- task response messages

Location Service

The package includes a location subsystem for enriching error reports with geographic data.

  • LocationCache -- Singleton cache backed by IMemoryCache. Caches IP addresses and location data with configurable TTLs.
  • LocationClient -- Fetches the machine's public IP via api.ipify.org and resolves location via ipinfo.io. Supports cached and uncached modes.
  • LocationService -- Scoped interface for application code to request location fields.

Supported location fields: "ip", "city", "region", "loc".

var city = await locationService.GetLocationInformation("city");
var region = await locationService.GetLocationInformation("region");

Telemetry

All operations emit OpenTelemetry traces via System.Diagnostics.ActivitySource. Activity sources are created for:

  • SQS.Service -- high-level publish operations
  • SQS.Client -- low-level SQS API calls
  • Location.Service -- location lookups
  • Location.Client -- IP and geolocation fetches
  • Location.Cache -- cache hits and misses

Traces include semantic messaging conventions (messaging.system, messaging.destination, messaging.message_id) for integration with observability platforms.

Error Handling

  • All SQS publish operations catch exceptions internally and return "error" on failure.
  • Errors are logged via ILogger.
  • SendLoggingMessage performs deduplication: repeated identical errors are not re-published.
  • When anonymous error reporting is enabled, usernames are stripped from messages and metadata.

API Overview

The ISqsService interface provides the following methods:

  • Task<string> SendLoggingMessage(TrelloMessageQueueModel message) -- Sends a logging message with deduplication, anonymization, and location enrichment. Returns the message ID on success.

  • Task<string> PublishMessage(TrelloMessageQueueModel message, string messageGroupID = null) -- Publishes a general message. Supports FIFO queue grouping via messageGroupID.

  • Task<string> PublishResponseMessage(TrelloMessageQueueResponseModel message, string messageGroupID = null) -- Publishes a response message for request/response patterns. Supports FIFO grouping.

  • Task<string> PublishMaintenanceMessage(TrelloMessageQueueModel message, string messageGroupID = null) -- Sends a maintenance message with optional FIFO grouping.

  • Task<string> PublishTaskMessageToClient(RemoteHostTaskQueueModel message, string messageGroupID = null) -- Publishes a task message to a specific remote host's queue.

  • Task<string> PublishTaskMessageResponse(RemoteHostTaskQueueModel message, string messageGroupID = null) -- Publishes a response to a previously sent task message.

  • string GetUserName() -- Returns the current username, or "Anonymous" when anonymous reporting is enabled.

  • string GetMachineName() -- Returns the machine name, or "Anonymous" when anonymous reporting is enabled.

  • string ParseDescription(string text) -- Strips the current username from the provided text for anonymization.

Dependencies

License

MIT License

Contributing

Contributions are welcome! Please submit issues or pull requests for improvements.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on Davasorus.Utility.DotNet.SQS:

Package Downloads
Davasorus.Utility.DotNet.Api

API Interaction for TEPS Utilities with generic deserialization, configurable error reporting, and improved DI configuration. Supports REST, GraphQL, gRPC, WebSocket, SignalR, and SSE protocols.

Davasorus.Utility.DotNet.SQL

SQL interaction code for TEPS Utilities

Davasorus.Utility.DotNet.Services

Windows Service management (start, stop, enable, disable, enumerate) for TEPS Utilities, with OpenTelemetry tracing and DI-based wiring. Targets .NET 8 and .NET 10.

Davasorus.Utility.DotNet.Config

Manipulating config file for TEPS Utilities

Davasorus.Utility.DotNet.Caching

UCaching for TEPS Utilities

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2026.2.2.9 239 5/31/2026
2026.2.2.8 434 5/29/2026
2026.2.2.7 538 5/25/2026
2026.2.2.6 1,134 5/23/2026
2026.2.2.4 1,336 5/15/2026
2026.2.2.3 952 5/5/2026
2026.2.2.2 1,049 5/1/2026
2026.2.2.1 110 5/1/2026
2026.2.1.4 147 4/30/2026
2026.2.1.3 198 4/16/2026
2026.2.1.2 4,710 4/9/2026
2026.2.1.1 1,246 4/1/2026
2026.1.3.6 687 3/29/2026
2026.1.3.5 859 3/24/2026
2026.1.3.4 229 3/18/2026
2026.1.3.3 1,330 3/12/2026
2026.1.3.2 109 3/12/2026
2026.1.3.1 595 3/10/2026
2026.1.2.4 1,630 2/17/2026
2026.1.2.2 743 2/13/2026
Loading failed