Title: Add idempotency pipeline behavior for at-least-once command delivery
Labels: enhancement, mediator, new-package
Body:
Problem
In event-driven systems using Cortex.Streams with Kafka (at-least-once delivery), the same command may be dispatched multiple times. Without idempotency support, this causes duplicate side effects.
Proposed Solution
Create a Cortex.Mediator.Behaviors.Idempotency package:
IIdempotentCommand interface with IdempotencyKey property
IdempotencyCommandBehavior<TCommand, TResult> -- checks if a command with the same key was already processed, returns the cached result if so
IIdempotencyStore interface with in-memory and pluggable (e.g., database/Redis) implementations
- Configurable TTL for idempotency records
public class ProcessPaymentCommand : ICommand<PaymentResult>, IIdempotentCommand
{
public string IdempotencyKey => $"payment-{OrderId}-{Amount}";
public Guid OrderId { get; set; }
public decimal Amount { get; set; }
}
Title: Add idempotency pipeline behavior for at-least-once command delivery
Labels:
enhancement,mediator,new-packageBody:
Problem
In event-driven systems using Cortex.Streams with Kafka (at-least-once delivery), the same command may be dispatched multiple times. Without idempotency support, this causes duplicate side effects.
Proposed Solution
Create a
Cortex.Mediator.Behaviors.Idempotencypackage:IIdempotentCommandinterface withIdempotencyKeypropertyIdempotencyCommandBehavior<TCommand, TResult>-- checks if a command with the same key was already processed, returns the cached result if soIIdempotencyStoreinterface with in-memory and pluggable (e.g., database/Redis) implementations