I see two different ways of designing saga. What design will
axonframework support
1) Separate handlers from saga
http://jonathan-oliver.blogspot.com/2010/09/cqrs-sagas-with-event-sourcing-part-ii.html
public interface ISaga
{
Guid Id { get; }
long Version { get; }
// handler call Transition
void Transition(object message);
ICollection GetUncommittedEvents();
void ClearUncommittedEvents();
ICollection GetUndispatchedMessages();
void ClearUndispatchedMessages();
}
2) Saga with handler
http://www.udidahan.com/2009/04/20/saga-persistence-and-event-driven-architectures/
public class ShippingSaga : Saga<ShippingSagaData>,
ISagaStartedBy<OrderAccepted>,
ISagaStartedBy<CustomerBilledForOrder>
{
public void Handle(CustomerBilledForOrder message) {
this.Data.CustomerHasBeenBilled = true;
this.Data.CustomerId = message.CustomerId;
this.Data.OrderId = message.OrderId;
this.CompleteIfPossible();
}