Pisum.EventBus 1.8.0
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
No packages depend on Pisum.EventBus.
.NET 10.0
- Microsoft.EntityFrameworkCore (>= 10.0.2)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.2)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 10.0.0)
| Version | Downloads | Last updated |
|---|---|---|
| 1.8.0 | 4 | 01/29/2026 |