FlowCore 2.2.0
See the version list below for details.
dotnet add package FlowCore --version 2.2.0
NuGet\Install-Package FlowCore -Version 2.2.0
<PackageReference Include="FlowCore" Version="2.2.0" />
<PackageVersion Include="FlowCore" Version="2.2.0" />
<PackageReference Include="FlowCore" />
paket add FlowCore --version 2.2.0
#r "nuget: FlowCore, 2.2.0"
#:package FlowCore@2.2.0
#addin nuget:?package=FlowCore&version=2.2.0
#tool nuget:?package=FlowCore&version=2.2.0
📦 FlowCore
FlowCore is a .NET 8+ framework for CQRS, Event-Driven and Microservices architectures. It provides an extensible Mediator with Pipeline Behaviors, multi-provider EventBus (RabbitMQ, Kafka, InMemory), Outbox, Inbox, Saga, Scheduling, Retry, DLQ, OpenTelemetry, Execution Scope, Handler Discovery (hybrid: Source Generator + reflection fallback), Module Manifest, Health Checks, Metrics Context, Resilience Policies, Hosted Workers, Plugin Model and Testing Infrastructure.
🎯 Features
CQRS + Pipeline
- Commands, Queries and Events
- Pipeline Behaviors: Logging, Validation (FluentValidation), Caching, Transactions (EF Core), Event Dispatcher
- Hybrid Handler Discovery:
GeneratedHandlerRegistry(compile-time) with reflection fallback - Optional Source Generator to eliminate Runtime Reflection
EventBus
IEventBus— single abstraction for event publishing- Providers: InMemory (default), RabbitMQ, Kafka
DiagnosticsEventBus— decorator with tracing, metrics andIDiagnosticsContext- Providers as
IMessageProviderwith Start/Stop lifecycle managed byBootstrapCoordinator
Module Manifest
IModuleManifest— official identity of each module (Name, Version, Capabilities, Dependencies)IModuleRegistry— central catalog of all loaded modulesPluginModule— base class for third-party plugins- Automatic version compatibility validation on Bootstrap
Hosting & Application Lifecycle
IBootstrapCoordinator— ordered startup and shutdown (Core → Providers → Workers)BootstrapHostedService— integration with .NET Generic Host- Reverse shutdown order: Workers → Providers → Core
- Startup failures abort initialization; shutdown failures never block
Hosted Workers
IHostedWorker— unified interface for continuous processing workersIHostedWorkerManager— manages all workers lifecycle- Each work unit creates a new
ExecutionScope(mandatory isolation) - Supports: RabbitMQ Consumer, Kafka Consumer, Outbox, Inbox, Scheduler, Dead Letter
Health Checks
IHealthCheck— component health verification interfaceHealthCheckResultwith Status (Healthy, Degraded, Unhealthy), Duration, MetadataIHealthCheckRegistry— centralized check registration- ASP.NET Core Health Checks integration via
AddHealthCheck<T>() - Each module registers only its own checks
Metrics Context
IMetricsContext— per-ExecutionScopemetrics collectionMetricEntrywith Name, Type (Counter, Gauge, Histogram, Timer), Value, Tags- Pipeline, EventBus, Providers, Retry and Scheduler can record metrics
- Isolated context per execution — never shared between executions
Resilience
IResiliencePolicy— unified resilience policy abstraction- Policies: Timeout, Circuit Breaker, Bulkhead, Fallback, Rate Limiter
PolicyComposer— chained composition of multiple policies- Integration with Pipeline, EventBus and Providers
- Existing
IRetryPolicy+ImmediateRetryPolicy
Messaging Providers
- RabbitMQ —
AddRabbitMQ()with publish/consumer worker, auto-reconnect - Kafka —
AddKafka()with publish/consumer groups, managed commit - Registered via
IProviderRegistry+ lifecycle managed by Bootstrap
Transactional Patterns
- Outbox — reliable publishing with
IOutboxStore+OutboxWorker - Inbox — idempotent processing with
IInboxStore(deduplication by MessageId) - Saga Orchestration —
SagaCoordinatorwith steps, reverse-order compensation - Scheduled Messages — absolute/relative scheduling with
IMessageScheduler
Observability
IActivityFactory+IMetricRecorder(no-op by default, zero overhead)IDiagnosticsContextwithDiagnosticEntrycentralized inExecutionScope- Distributed tracing with CorrelationId propagation
Execution Scope
IExecutionScope— shared context per execution (CorrelationId, Items, Diagnostics, Metrics)AsyncLocalthread-safe, available without DI in Pipeline, Behaviors, Handlers and Providers
Plugin Model
PluginModule— base class for plugins extending FlowCore- Mandatory
ModuleManifestwithMinimumFlowCoreVersionfor validation - Plugins can register: Providers, Workers, Behaviors, Health Checks, Metrics
- Bootstrap treats plugins and official modules identically
AOT Compatibility
- Preferred path via Source Generators (zero runtime reflection)
- Reflection fallback annotated with
[RequiresDynamicCode]and[RequiresUnreferencedCode] FlowMediator,HandlerDiscoveryandDispatcherCacheprioritize generated code- Ready for Native AOT and Linker Trimming
Testing Infrastructure
FlowCore.Testing— NuGet package withFakeEventBus,FakeClock,IFlowCoreTestBuilder- Test environment setup without external infrastructure
- Isolation via
ExecutionScopeidentical to runtime
📥 Installation
Core
dotnet add package FlowCore --version 2.2.0
Providers
dotnet add package FlowCore.RabbitMQ --version 2.2.0
dotnet add package FlowCore.Kafka --version 2.2.0
Testing
dotnet add package FlowCore.Testing --version 2.2.0
⚙️ Configuration
Basic
builder.Services.AddFlowCore();
With RabbitMQ
builder.Services
.AddFlowCore()
.AddRabbitMQ(options =>
{
options.Host = "localhost";
options.Username = "guest";
options.Password = "guest";
});
With Kafka
builder.Services
.AddFlowCore()
.AddKafka(options =>
{
options.BootstrapServers = "localhost:9092";
options.ConsumerGroup = "my-service";
});
Optional modules
builder.Services
.AddFlowCore()
.AddFlowCoreTransactions() // EF Core transaction scope
.AddFlowCoreOutbox() // Outbox Worker
.AddFlowCoreDiagnostics() // System.Diagnostics Activity + Metrics
.AddFlowCoreSagaListener() // Saga event listener
.AddFlowCoreScheduler(); // Scheduled Messages Worker
Custom module with Manifest
public class MyModule : IFlowCoreModule
{
public IModuleManifest Manifest { get; }
= new ModuleManifest("MyModule", new Version(1, 0, 0),
["CustomProvider", "HealthCheck"]);
public void Configure(IFlowCoreBuilder builder)
{
builder.AddHealthCheck<MyHealthCheck>();
builder.AddHostedWorker<MyWorker>();
}
}
builder.Services.AddFlowCore().AddModule<MyModule>();
Custom Health Check
public class MyHealthCheck : IHealthCheck
{
public async ValueTask<HealthCheckResult> CheckAsync(CancellationToken ct)
{
return HealthCheckResult.Healthy("my-component", "All ok");
}
}
Resilience policy
var pipeline = new PolicyComposer(
new CircuitBreakerPolicy(failureThreshold: 3),
new TimeoutPolicy(TimeSpan.FromSeconds(5)));
💡 Usage Examples
Commands and Queries
public record CreateUserCommand(string Name, string Email) : ICommand<Guid>;
public class CreateUserHandler : ICommandHandler<CreateUserCommand, Guid>
{
public async Task<Guid> HandleAsync(CreateUserCommand command, CancellationToken ct)
{
var user = new User { Id = Guid.NewGuid(), Name = command.Name, Email = command.Email };
return user.Id;
}
}
var userId = await _mediator.SendAsync(new CreateUserCommand("John", "john@email.com"));
Events
public record UserCreatedEvent(Guid UserId) : IEvent;
public class UserCreatedHandler : IEventHandler<UserCreatedEvent>
{
public Task HandleAsync(UserCreatedEvent @event, CancellationToken ct)
{
Console.WriteLine($"User created: {@event.UserId}");
return Task.CompletedTask;
}
}
await _eventBus.PublishAsync(new UserCreatedEvent(userId));
Scheduled Messages
await _scheduler.ScheduleAfterAsync(
new OrderExpiredEvent(orderId),
TimeSpan.FromHours(2));
Saga
public class OrderSaga : Saga
{
public override Task DefineStepsAsync()
{
AddStep<OrderPlacedEvent>("ReserveInventory", async (evt, ct) =>
{
// execute
}, compensate: async (evt, ct) =>
{
// compensate if later step fails
});
AddStep<PaymentProcessedEvent>("ProcessPayment", async (evt, ct) =>
{
// execute
});
return Task.CompletedTask;
}
}
builder.Services.AddSaga<OrderSaga>();
builder.Services.AddFlowCoreSagaListener();
✅ Tests
21 unit tests covering Mediator, Behaviors, DI, EventBus, Serialization, Retry, DLQ, Outbox, Inbox, Tracing, Saga, and Scheduling.
dotnet test
For testing applications that use FlowCore, use the FlowCore.Testing package:
var services = new ServiceCollection();
var builder = services.CreateTestBuilder();
var provider = builder.Build();
var fakeBus = provider.GetFakeEventBus();
// Execute scenario...
Assert.Single(fakeBus.Published);
📄 License
MIT License
| Product | Versions 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. |
-
net8.0
- FluentValidation (>= 11.11.0)
- Microsoft.EntityFrameworkCore (>= 8.0.15)
- Microsoft.Extensions.DependencyInjection (>= 8.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Logging (>= 8.0.1)
- Scrutor (>= 6.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v2.2.0:
- Module Manifest: IModuleManifest + IModuleRegistry para metadados de módulos
- Hosting & Application Lifecycle: Bootstrap e Shutdown ordenados
- Metrics Context: IMetricsContext + MetricEntry por Execution Scope
- Health Checks: IHealthCheck + IHealthCheckRegistry + ASP.NET Core integration
- Resilience: IResiliencePolicy + Circuit Breaker, Timeout, Bulkhead, Fallback, Rate Limiter
- Hosted Workers: IHostedWorker + IHostedWorkerManager unificados
- Plugin Model: plugins como cidadãos de primeira classe via Builder
- Testing Infrastructure: FlowCore.Testing com Fake Providers e Test Builder
- Source Generators: caminho preferencial com fallback reflection (híbrido)
- AOT Compatibility: zero reflection em runtime nos caminhos gerados