Title: Add transactional outbox behavior for reliable event publishing with Cortex.Streams
Labels: enhancement, mediator, new-package
Body:
Problem
When a command handler persists data and publishes notifications/events, there's a consistency gap: the database commit can succeed but the notification publish can fail (or vice versa). The transactional outbox pattern solves this by writing events to an outbox table within the same database transaction, then a background process relays them to the event bus.
This bridges the gap between Cortex.Mediator (in-process commands) and Cortex.Streams (event streaming).
Proposed Solution
Create a Cortex.Mediator.Outbox package:
IOutboxStore interface for persisting outbox messages (with EF Core and Dapper implementations)
OutboxCommandBehavior<TCommand, TResult> -- captures notifications published during command handling and writes them to the outbox within the same transaction
OutboxRelayService -- IHostedService that polls the outbox and publishes to Cortex.Streams
[PublishToOutbox] attribute to opt-in specific notifications
Relationship to Existing Packages
- Uses
Cortex.Mediator.Behaviors.Transactional for transaction management
- Publishes to
Cortex.Streams for event distribution
Title: Add transactional outbox behavior for reliable event publishing with Cortex.Streams
Labels:
enhancement,mediator,new-packageBody:
Problem
When a command handler persists data and publishes notifications/events, there's a consistency gap: the database commit can succeed but the notification publish can fail (or vice versa). The transactional outbox pattern solves this by writing events to an outbox table within the same database transaction, then a background process relays them to the event bus.
This bridges the gap between
Cortex.Mediator(in-process commands) andCortex.Streams(event streaming).Proposed Solution
Create a
Cortex.Mediator.Outboxpackage:IOutboxStoreinterface for persisting outbox messages (with EF Core and Dapper implementations)OutboxCommandBehavior<TCommand, TResult>-- captures notifications published during command handling and writes them to the outbox within the same transactionOutboxRelayService--IHostedServicethat polls the outbox and publishes to Cortex.Streams[PublishToOutbox]attribute to opt-in specific notificationsRelationship to Existing Packages
Cortex.Mediator.Behaviors.Transactionalfor transaction managementCortex.Streamsfor event distribution