Interface ISagaCoordinator
Defines the contract for saga coordination services that manage the lifecycle and event routing for saga instances within the distributed messaging system. The coordinator is responsible for finding appropriate saga instances, routing events, and managing saga state transitions.
public interface ISagaCoordinator
- Extension Methods
Remarks
The saga coordinator serves as the central orchestration point for saga pattern implementation, handling event correlation, saga instance resolution, and coordination of complex business processes. It bridges between the messaging infrastructure and individual saga instances, ensuring proper event routing and saga lifecycle management in distributed system architectures.
Methods
ProcessEventAsync(IMessageContext, ISagaEvent, CancellationToken)
Asynchronously processes a saga event by routing it to appropriate saga instances and coordinating any resulting state transitions or actions within the business process.
[RequiresUnreferencedCode("The JIT dispatch path uses MakeGenericMethod over runtime saga types. Register typed dispatch via ISagaDispatchRegistry (or the saga registration source generator) for a trim/AOT-safe path.")]
[RequiresDynamicCode("The JIT dispatch path uses MakeGenericMethod over runtime saga types. Register typed dispatch via ISagaDispatchRegistry (or the saga registration source generator) for a trim/AOT-safe path.")]
Task ProcessEventAsync(IMessageContext messageContext, ISagaEvent evt, CancellationToken cancellationToken)
Parameters
messageContextIMessageContextThe message processing context containing metadata, correlation information, and processing state accumulated during message pipeline execution.
evtISagaEventThe saga event to process, containing business data and correlation information needed for saga instance resolution and state updates.
cancellationTokenCancellationTokenToken to monitor for cancellation requests during saga event processing.
Returns
- Task
A task that represents the asynchronous saga event processing operation.
Remarks
This method orchestrates the complete saga event processing workflow: - Correlates events with existing saga instances or creates new instances as needed - Routes events to appropriate saga handlers based on event type and saga state - Manages saga state persistence and recovery operations - Coordinates any downstream actions or command dispatching triggered by state transitions
The coordinator ensures saga consistency and handles both success and failure scenarios, including compensation logic and error recovery procedures.