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

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 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

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