Fermion.EventBus.InMemory 1.0.0

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Fermion.EventBus.InMemory --version 1.0.0
                    
NuGet\Install-Package Fermion.EventBus.InMemory -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="Fermion.EventBus.InMemory" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Fermion.EventBus.InMemory" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Fermion.EventBus.InMemory" />
                    
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 Fermion.EventBus.InMemory --version 1.0.0
                    
#r "nuget: Fermion.EventBus.InMemory, 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 Fermion.EventBus.InMemory@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=Fermion.EventBus.InMemory&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Fermion.EventBus.InMemory&version=1.0.0
                    
Install as a Cake Tool

Fermion.EventBus.InMemory

Fermion.EventBus.InMemory is a NuGet package that provides an in-memory implementation of the event bus for .NET applications. It's designed for testing and single-instance applications where a distributed message broker is not required.

Features

  • 🚀 In-memory event processing using channels
  • 🔄 Asynchronous event handling
  • 📦 Easy integration with dependency injection
  • 🔍 Automatic subscription management
  • 🛡️ Error handling and logging
  • 🏗️ Extensible architecture

Installation

  dotnet add package Fermion.EventBus.InMemory

Usage

1. Define Your Event

public class UserCreatedEvent : IntegrationEvent
{
    public string UserId { get; set; }
    public string UserName { get; set; }
}

2. Create an Event Handler

public class UserCreatedEventHandler : IIntegrationEventHandler<UserCreatedEvent>
{
    private readonly ILogger<UserCreatedEventHandler> _logger;

    public UserCreatedEventHandler(ILogger<UserCreatedEventHandler> logger)
    {
        _logger = logger;
    }

    public async Task Handle(UserCreatedEvent @event)
    {
        _logger.LogInformation("User created: {UserId}, {UserName}",
            @event.UserId, @event.UserName);
        await Task.CompletedTask;
    }
}

3. Configure EventBus

services.AddEventBusInMemory(options =>
{
    options.SubscriberClientAppName = AppDomain.CurrentDomain.FriendlyName;
    options.EventNamePrefix = string.Empty;
    options.EventNameSuffix = string.Empty;

    // Register event handlers
    options.AddEventHandler<UserCreatedEventHandler>();

    // Add subscriptions
    options.AddSubscription<UserCreatedEvent, UserCreatedEventHandler>();
});

4. Publish and Subscribe to Events

public class UserController : ControllerBase
{
    private readonly IEventBus _eventBus;

    public UserController(IEventBus eventBus)
    {
        _eventBus = eventBus;
    }

    [HttpPost]
    public async Task<IActionResult> CreateUser(CreateUserRequest request)
    {
        // Create user logic...

        await _eventBus.PublishAsync(new UserCreatedEvent 
        { 
            UserId = "123", 
            UserName = "John Doe" 
        });

        return Ok();
    }
}

Configuration Options

Option Description Default
SubscriberClientAppName Subscriber client application name Application name
EventNamePrefix Prefix for event names ""
EventNameSuffix Suffix for event names ""

Event Handler Registration

The package provides two methods for registering event handlers:

  1. Using AddEventHandler<T>():

    options.AddEventHandler<UserCreatedEventHandler>();
    
  2. Using AddSubscription<TEvent, THandler>():

    options.AddSubscription<UserCreatedEvent, UserCreatedEventHandler>();
    

Error Handling

The in-memory event bus includes built-in error handling and logging:

  • Event processing errors are caught and logged
  • Failed event processing doesn't affect other events
  • Detailed error information is available in logs

Best Practices

  1. Use for testing and single-instance applications
  2. Register all event handlers during startup
  3. Implement proper error handling in event handlers
  4. Use logging for monitoring and debugging
  5. Consider using the distributed event bus for production environments
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