NotiCOO.Core.Consumer
1.0.0
dotnet add package NotiCOO.Core.Consumer --version 1.0.0
NuGet\Install-Package NotiCOO.Core.Consumer -Version 1.0.0
<PackageReference Include="NotiCOO.Core.Consumer" Version="1.0.0" />
<PackageVersion Include="NotiCOO.Core.Consumer" Version="1.0.0" />
<PackageReference Include="NotiCOO.Core.Consumer" />
paket add NotiCOO.Core.Consumer --version 1.0.0
#r "nuget: NotiCOO.Core.Consumer, 1.0.0"
#:package NotiCOO.Core.Consumer@1.0.0
#addin nuget:?package=NotiCOO.Core.Consumer&version=1.0.0
#tool nuget:?package=NotiCOO.Core.Consumer&version=1.0.0
NotiCOO.Core.Consumer
RabbitMQ consumer wrapper library for the NotiCOO notification system.
Overview
This package provides a clean, generic wrapper for RabbitMQ consumer functionality. It abstracts the RabbitMQ implementation details and provides interfaces for message processing that can be implemented by consuming applications.
Features
- Generic message consumer interface (
IMessageConsumer
) - RabbitMQ-specific consumer implementation (
IRabbitMqConsumer
,RabbitMqConsumer
) - Generic message processor interface (
IMessageProcessor<T>
) - Base message processor with JSON deserialization (
MessageProcessor<T>
) - Dependency injection extensions
- Built-in error handling and logging
Usage
Installation
dotnet add package NotiCOO.Core.Consumer
Basic Setup
using NotiCOO.Core.Consumer.Extensions;
using NotiCOO.Core.Models;
// Configure services
builder.Services.Configure<RabbitMqConfiguration>(
builder.Configuration.GetSection("RabbitMQ"));
// Add core consumer
builder.Services.AddNotiCOOCoreConsumer();
Creating a Custom Message Processor
using NotiCOO.Core.Consumer.Services;
using NotiCOO.Core.Models;
public class MyNotificationProcessor : MessageProcessor<NotificationMessage>
{
public MyNotificationProcessor(ILogger<MessageProcessor<NotificationMessage>> logger)
: base(logger) { }
public override async Task<bool> ProcessMessageAsync(NotificationMessage message)
{
// Your custom processing logic here
Logger.LogInformation("Processing notification: {Title}", message.Title);
// Process the message...
return true; // Return success/failure
}
}
Registering Custom Processors
// Register your custom processor
builder.Services.AddScoped<MyNotificationProcessor>();
// Or use the extension method
builder.Services.AddMessageProcessor<MyNotificationProcessor, NotificationMessage>();
Manual Consumer Usage
public class MyBackgroundService : BackgroundService
{
private readonly IRabbitMqConsumer _consumer;
private readonly MyNotificationProcessor _processor;
public MyBackgroundService(IRabbitMqConsumer consumer, MyNotificationProcessor processor)
{
_consumer = consumer;
_processor = processor;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
_consumer.MessageReceived += async (message) =>
{
await _processor.ProcessRawMessageAsync(message);
};
await _consumer.StartAsync(stoppingToken);
// Keep running...
await Task.Delay(Timeout.Infinite, stoppingToken);
}
}
Configuration
Configure RabbitMQ settings in appsettings.json
:
{
"RabbitMQ": {
"HostName": "localhost",
"Port": 5672,
"UserName": "guest",
"Password": "guest",
"VirtualHost": "/",
"ExchangeName": "notifications",
"QueueName": "notification-queue",
"RoutingKey": "notification",
"Durable": true,
"AutoDelete": false,
"Exclusive": false,
"PrefetchCount": 10
}
}
Interfaces
IMessageConsumer
Generic interface for message consumers.
IRabbitMqConsumer
RabbitMQ-specific consumer interface extending IMessageConsumer
.
IMessageProcessor<T>
Generic interface for processing messages of type T.
Dependencies
- NotiCOO.Core
- RabbitMQ.Client
- Microsoft.Extensions.Hosting.Abstractions
- Microsoft.Extensions.Logging.Abstractions
- Microsoft.Extensions.DependencyInjection.Abstractions
- Microsoft.Extensions.Options
NuGet Package
Package ID: NotiCOO.Core.Consumer
Product | Versions 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. |
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
- NotiCOO.Core (>= 1.0.0)
- RabbitMQ.Client (>= 7.1.2)
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 |
---|---|---|
1.0.0 | 147 | 7/28/2025 |