SimpleAzureQueueConsumer 0.4.0

dotnet add package SimpleAzureQueueConsumer --version 0.4.0
                    
NuGet\Install-Package SimpleAzureQueueConsumer -Version 0.4.0
                    
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="SimpleAzureQueueConsumer" Version="0.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SimpleAzureQueueConsumer" Version="0.4.0" />
                    
Directory.Packages.props
<PackageReference Include="SimpleAzureQueueConsumer" />
                    
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 SimpleAzureQueueConsumer --version 0.4.0
                    
#r "nuget: SimpleAzureQueueConsumer, 0.4.0"
                    
#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 SimpleAzureQueueConsumer@0.4.0
                    
#: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=SimpleAzureQueueConsumer&version=0.4.0
                    
Install as a Cake Addin
#tool nuget:?package=SimpleAzureQueueConsumer&version=0.4.0
                    
Install as a Cake Tool

SimpleAzureQueueConsumer

Description

SimpleAzureQueueConsumer is a .NET library that simplifies working with Azure Storage Queues. It provides an easy way to register message handlers with support for singleton, scoped, and transient lifecycles, along with a robust message dispatching mechanism.

It is a dead simple implementation, which uses a background service to poll messages from the Azure Storage Queue and dispatches them to the registered handlers. The library is designed to be lightweight and customizable, allowing developers to focus on building their message-driven systems without worrying about the underlying complexities.

To keep it simple, it will always just forward the message body a string to the handler. If you need to work with more complex message types, you can deserialize the message body in the handler.

If an unhandled exception occurs in the handler, the message will be retried 5 times, and finally sent to an error queue.

This package is designed for developers building message-driven systems using Azure Storage Queues.


Features

  • Keyed service registration for different queues.
  • Built-in polling mechanism with configurable intervals.
  • Easy integration with .NET's dependency injection (DI).
  • Lightweight and customizable.

Getting Started

Installation

You can install the package using the .NET CLI:

dotnet add package SimpleAzureQueueConsumer
<PackageReference Include="SimpleAzureQueueConsumer" Version="1.0.0" />

Usage

Here's a simple example of how you can use the SimpleAzureQueueConsumer library:

var builder = WebApplication.CreateBuilder(args);
var services = builder.Services;

// Add base configuration
services.AddSaqcBase("YourAzureStorageConnectionString");

// Register handlers using the fluent API
builder.Services.AddSaqcHandler<OrderCreatedMessageHandler>()
    .OnQueue("order-created")
    .SetPollingRate(5000)
    .Register();

builder.Services.AddSaqcHandler<UserCreatedMessageHandler>()
    .OnQueue("user-created")
    .SetPollingRate(5000)
    .Register();

var app = builder.Build();
app.Run();

Create a new class that implements the IQueueMessageHandler interface:

// Example message handler
public class OrderCreatedMessageHandler : IQueueMessageHandler
{
    public Task HandleMessageAsync(string message)
    {
        // Process the order created message
        Console.WriteLine($"Order created message received: {message}");
        // ... your order processing logic ...
        return Task.CompletedTask;
    }
}

Requirements

  • .NET 6.0 or later (We are using keyed services, which are available in .NET 6.0 and later).
  • Azure Storage Account with a Queue service.
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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

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.4.0 158 12/30/2024
0.3.1 146 12/30/2024
0.3.0 148 12/27/2024