SimpleAzureQueueConsumer 0.4.0
dotnet add package SimpleAzureQueueConsumer --version 0.4.0
NuGet\Install-Package SimpleAzureQueueConsumer -Version 0.4.0
<PackageReference Include="SimpleAzureQueueConsumer" Version="0.4.0" />
<PackageVersion Include="SimpleAzureQueueConsumer" Version="0.4.0" />
<PackageReference Include="SimpleAzureQueueConsumer" />
paket add SimpleAzureQueueConsumer --version 0.4.0
#r "nuget: SimpleAzureQueueConsumer, 0.4.0"
#:package SimpleAzureQueueConsumer@0.4.0
#addin nuget:?package=SimpleAzureQueueConsumer&version=0.4.0
#tool nuget:?package=SimpleAzureQueueConsumer&version=0.4.0
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 | Versions 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. |
-
net6.0
- Azure.Storage.Queues (>= 12.21.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
-
net7.0
- Azure.Storage.Queues (>= 12.21.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
-
net8.0
- Azure.Storage.Queues (>= 12.21.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.