pisum

Pisum.EventBus (1.9.0)

Published 2026-04-14 13:27:20 +02:00 by mschnecke

Installation

dotnet nuget add source --name pisum --username your_username --password your_token 
dotnet add package --source pisum --version 1.9.0 Pisum.EventBus

About this package

A comprehensive .NET event bus library providing reliable, distributed event processing with Entity Framework Core, PostgreSQL, and InMemory capabilities.

Pisum.EventBus

A comprehensive .NET event bus library providing reliable, distributed event processing with Entity Framework Core, PostgreSQL, and InMemory capabilities.

Features

  • Dual Storage Modes: Database-backed (PostgreSQL) and in-memory implementations
  • Reliable Processing: Automatic retry mechanisms with configurable delays and attempts
  • Dead Letter Queue: Failed events are moved to dead letter storage after retry exhaustion
  • Event-driven Architecture: Clean separation between event publishers and handlers
  • Background Processing: Asynchronous event processing with hosted services
  • State Change Notifications: Subscribe to event state transitions with flexible filtering
  • Type-safe Events: Strongly-typed event system with JSON serialization

Quick Start

Installation

dotnet add package Pisum.EventBus

Define Events

public class OrderCreatedEvent : BaseEvent
{
    public Guid OrderId { get; set; }
    public string CustomerEmail { get; set; }
    public decimal TotalAmount { get; set; }
}

Create Event Handlers

public class OrderCreatedHandler : IEventHandler<OrderCreatedEvent>
{
    public async Task<Result> HandleAsync(OrderCreatedEvent @event, CancellationToken cancellationToken)
    {
        // Send confirmation email, update analytics, process business logic
        return Result.Success();
    }
}

Configure Services

// Database (production)
services.AddPisumEventBus(configuration.GetSection("EventBus").Get<EventBusOptions>());

// In-memory (development/testing)
services.AddPisumEventBus(options =>
{
    options.UseInMemory = true;
    options.ProcessingEnabled = true;
});

Publish Events

public class OrdersController : ControllerBase
{
    private readonly IEventBus _eventBus;

    public async Task<IActionResult> CreateOrder(CreateOrderRequest request)
    {
        // Create order logic...
        await _eventBus.PublishAsync(new OrderCreatedEvent
        {
            OrderId = orderId,
            CustomerEmail = request.Email,
            TotalAmount = request.Total
        });
        return Ok();
    }
}

Configuration

Database Configuration (appsettings.json)

{
  "EventBus": {
    "ConnectionString": "Host=localhost;Database=eventbus;Username=user;Password=pass",
    "MaxRetryAttempts": 3,
    "RetryDelay": "00:05:00",
    "LeaseTimeout": "00:05:00",
    "ProcessingEnabled": true
  }
}

In-Memory Configuration

services.AddPisumEventBus(options =>
{
    options.UseInMemory = true;
    options.MaxRetryAttempts = 3;
    options.RetryDelay = TimeSpan.FromMinutes(5);
    options.ProcessingEnabled = true;
});

Event States

  • Pending: Newly created, awaiting processing
  • Processing: Currently being handled
  • Processed: Successfully completed
  • Failed: Moved to dead letter queue after retry exhaustion

Requirements

  • .NET 10.0 or later
  • PostgreSQL 12+ (for database mode)

License

Copyright (c) 2025 pisum.net

Dependencies

ID Version Target Framework
Microsoft.EntityFrameworkCore 10.0.5 net10.0
Microsoft.EntityFrameworkCore.Relational 10.0.5 net10.0
Npgsql.EntityFrameworkCore.PostgreSQL 10.0.1 net10.0
Details
NuGet
2026-04-14 13:27:20 +02:00
1
pisum.net
64 KiB
Assets (2)
Versions (2) View all
1.9.0 2026-04-14
1.3.0 2026-04-14