Nera.Lib.Messaging.Abstractions 1.0.2

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

Nera.Lib.Messaging.Abstractions

Simplified Messaging Library for Nextera Services - Redesigned to be as simple as MediatR πŸš€

Overview

A lightweight messaging library that provides two distinct messaging patterns for microservices:

  • In-Service Events - Simple, MediatR-like events within the same service
  • External Events - Cross-service messaging using MassTransit + RabbitMQ

Key Features

  • βœ… Simple like MediatR - Familiar API for developers
  • βœ… Auto-discovery - Automatic handler registration
  • βœ… Proper lifetimes - Correct DI scoping
  • βœ… Error isolation - One failing handler won't crash others
  • βœ… Zero configuration - Works out of the box
  • βœ… Type-safe - Full compile-time type checking

Quick Start

1. Install Package

<PackageReference Include="Nera.Lib.Messaging.Abstractions" Version="1.0.0" />

2. Register Services

// Program.cs or Startup.cs
services.AddMessagingServices(); // Enables in-service events

// Optional: Add MassTransit for external messaging
services.AddMassTransitWithRabbitMq(
    consumers => consumers.AddConsumer<MyConsumer>(),
    (cfg, ctx) => cfg.ReceiveEndpoint("my-queue", e => e.ConfigureConsumer<MyConsumer>(ctx))
);

3. Create Event & Handler

// Define an event
public class UserCreated : IInServiceEvent
{
    public string UserId { get; set; }
    public string Email { get; set; }
}

// Create a handler
public class SendWelcomeEmailHandler : IInServiceEventHandler<UserCreated>
{
    public async Task Handle(UserCreated @event, CancellationToken cancellationToken)
    {
        // Handle the event
        await SendWelcomeEmail(@event.Email);
    }
}

4. Publish Events

public class UserService
{
    private readonly IInServiceEventBus _eventBus;

    public async Task CreateUser(CreateUserRequest request)
    {
        var user = await CreateUserLogic(request);
        
        // Publish event - all handlers will be called automatically
        await _eventBus.Publish(new UserCreated 
        { 
            UserId = user.Id, 
            Email = user.Email 
        });
    }
}

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Your Service                                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  In-Service Events (Fast, Same Process)                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚  β”‚  Publisher  │───▢│  IInServiceEventBus                 β”‚     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚  β”œβ”€ Handler 1                       β”‚     β”‚
β”‚                     β”‚  β”œβ”€ Handler 2                       β”‚     β”‚
β”‚                     β”‚  └─ Handler N                       β”‚     β”‚
β”‚                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  External Events (Reliable, Cross-Service)                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚  β”‚  Publisher  │───▢│  MassTransit + RabbitMQ             β”‚     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                Other Services                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                       β”‚
β”‚  β”‚  MassTransit Consumers              β”‚                       β”‚
β”‚  β”‚  β”œβ”€ Consumer 1                      β”‚                       β”‚
β”‚  β”‚  β”œβ”€ Consumer 2                      β”‚                       β”‚
β”‚  β”‚  └─ Consumer N                      β”‚                       β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Comparison

Feature In-Service Events External Events
Use Case Same service logic Cross-service communication
Performance Very fast (in-memory) Network calls
Reliability Process dependent Durable, retries
Scope Single service Multiple services
Interface IInServiceEvent IIntegrationEvent
Bus IInServiceEventBus IEventBus (MassTransit)

Migration from Old Version

Before (Complex)

// Complex registration
services.AddInServiceEventHandlers(Assembly.GetExecutingAssembly());

// Manual handler registration with reflection issues
public class Handler : InServiceEventHandlerBase<Event>
{
    // Required specific base class
}

// Event with required properties
public class Event : InServiceEventBase
{
    public Guid Id { get; set; } // Required
    public DateTimeOffset OccurredOn { get; set; } // Required
}

After (Simple)

// Simple registration - auto-discovery
services.AddMessagingServices();

// Flexible handler implementation
public class Handler : IInServiceEventHandler<Event>
{
    // Or optionally inherit from base class for logging
}

// Simple event definition
public class Event : IInServiceEvent
{
    // Only your business properties
}

Documentation

Requirements

  • .NET 9.0+
  • MassTransit 8.0+ (for external events)
  • RabbitMQ (for external events)

License

Internal Nextera library - Not for public distribution


Simple, Reliable, Type-Safe Messaging for Nextera Services πŸ’ͺ

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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 (2)

Showing the top 2 NuGet packages that depend on Nera.Lib.Messaging.Abstractions:

Package Downloads
Nera.Lib.Database

Database access layer with Entity Framework Core, Repository pattern, Specification pattern, and advanced querying capabilities for Nera applications

Nera.Lib.Messaging.Sender

A robust messaging sender library for Nera applications providing event-driven communication capabilities with logging, retry policies, and template variable substitution

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 36 9/28/2025
1.0.1 57 9/27/2025
1.0.0 280 9/9/2025