EventSourcedSaga, based on different persistence mechanisms as explained below) use a convention-based mapping for their registration and event handling. Events can be handled with void
Handle(IEventMessage<TEvent> ev)methods that take a single argument of type
TEventis the specific type of event to handle (its subtypes will not be matched). These methods need to be decorated with a
SagaMethodAttributethat specifies how the saga instances should be located. An example:
IConventionBasedSaga(applies for both mentioned saga base classes), this also means they will be automatically registered in the saga registry for the event types they implement if they are found in any of the referenced assemblies during the startup, so they are invoked when a saga event dispatch happens.
SagaMethodAttributespecifies what saga instances should the event be sent to. There are currently five options available:
SetSagaKey. Sagas can save multiple values for one key, allowing it to react to any of events correlated to them. It is also possible to specify multiple
SagaEventAttributesfor one method.
Sendmethod are queued and get actually processed by the command bus upon committing and saving the saga (which happens automatically when saga event processing is finished).
BasicSagas and persisting event stream of
EventSourcedSagas), because the system also internally uses the regular IRepository.